Author: hpoussin
Date: Wed May 3 17:56:12 2006
New Revision: 21787
URL:
http://svn.reactos.ru/svn/reactos?rev=21787&view=rev
Log:
Don't double free buffer in case of error
Modified:
trunk/reactos/dll/win32/setupapi/parser.c
Modified: trunk/reactos/dll/win32/setupapi/parser.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/win32/setupapi/parser.c…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/parser.c (original)
+++ trunk/reactos/dll/win32/setupapi/parser.c Wed May 3 17:56:12 2006
@@ -1988,8 +1988,7 @@
/* Allocate memory for file filter */
len = DirectoryPath ? strlenW(DirectoryPath) : MAX_PATH;
- pFileSpecification = HeapAlloc(
- GetProcessHeap(), 0,
+ pFileSpecification = MyMalloc(
(len + 1 + strlenW(InfFileSpecification) + 1) * sizeof(WCHAR));
if (!pFileSpecification)
{
@@ -2017,7 +2016,7 @@
hSearch = FindFirstFileW(pFileSpecification, &wfdFileInfo);
if (hSearch == INVALID_HANDLE_VALUE)
{
- HeapFree(GetProcessHeap(), 0, pFileSpecification);
+ TRACE("No file returned by %s\n", debugstr_w(pFileSpecification));
goto cleanup;
}
@@ -2053,10 +2052,12 @@
} while (FindNextFileW(hSearch, &wfdFileInfo));
FindClose(hSearch);
- ret = TRUE;
requiredSize += sizeof(WCHAR); /* Final NULL char */
if (requiredSize <= ReturnBufferSize)
+ {
*pBuffer = '\0';
+ ret = TRUE;
+ }
else
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
@@ -2066,7 +2067,7 @@
*RequiredSize = requiredSize;
cleanup:
- HeapFree(GetProcessHeap(), 0, pFileSpecification);
+ MyFree(pFileSpecification);
return ret;
}