allocate enough memory for strings, lstrlenW returns the length of the string in characters, not bytes. Modified: trunk/reactos/lib/setupapi/stringtable.c _____
Modified: trunk/reactos/lib/setupapi/stringtable.c --- trunk/reactos/lib/setupapi/stringtable.c 2005-07-08 16:37:07 UTC (rev 16510) +++ trunk/reactos/lib/setupapi/stringtable.c 2005-07-08 19:21:28 UTC (rev 16511) @@ -200,7 +200,7 @@
{ 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 @@ { 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 @@ 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]);