From d556da508d546ccb62528134ab5088fbcf4bd7d1 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Fri, 8 Jul 2005 19:21:28 +0000 Subject: [PATCH] allocate enough memory for strings, lstrlenW returns the length of the string in characters, not bytes. svn path=/trunk/; revision=16511 --- reactos/lib/setupapi/stringtable.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/lib/setupapi/stringtable.c b/reactos/lib/setupapi/stringtable.c index fddb7262739..827cdc61e93 100644 --- a/reactos/lib/setupapi/stringtable.c +++ b/reactos/lib/setupapi/stringtable.c @@ -200,7 +200,7 @@ StringTableAddString(HSTRING_TABLE hStringTable, { if (pStringTable->pSlots[i] == NULL) { - pStringTable->pSlots[i] = MyMalloc(lstrlenW(lpString) + sizeof(WCHAR)); + pStringTable->pSlots[i] = MyMalloc((lstrlenW(lpString) + 1) * sizeof(WCHAR)); if (pStringTable->pSlots[i] == NULL) { TRACE("Couldn't allocate memory for a new string!\n"); @@ -276,7 +276,7 @@ StringTableDuplicate(HSTRING_TABLE hStringTable) { if (pSourceTable->pSlots[i] != NULL) { - length = lstrlenW(pSourceTable->pSlots[i]) + sizeof(WCHAR); + length = lstrlenW((pSourceTable->pSlots[i]) + 1) * sizeof(WCHAR); pDestinationTable->pSlots[i] = MyMalloc(length); if (pDestinationTable->pSlots[i] != NULL) { @@ -429,7 +429,7 @@ StringTableStringFromIdEx(HSTRING_TABLE hStringTable, return FALSE; } - dwLength = lstrlenW(pStringTable->pSlots[dwId]) + sizeof(WCHAR); + dwLength = (lstrlenW(pStringTable->pSlots[dwId]) + 1) * sizeof(WCHAR); if (dwLength <= *lpBufferLength) { lstrcpyW(lpBuffer, pStringTable->pSlots[dwId]);