mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 08:15:41 +00:00
Don't double free buffer in case of error
svn path=/trunk/; revision=21787
This commit is contained in:
parent
534b5a2027
commit
cdcd6ee015
1 changed files with 6 additions and 5 deletions
|
@ -1988,8 +1988,7 @@ SetupGetInfFileListW(
|
||||||
|
|
||||||
/* Allocate memory for file filter */
|
/* Allocate memory for file filter */
|
||||||
len = DirectoryPath ? strlenW(DirectoryPath) : MAX_PATH;
|
len = DirectoryPath ? strlenW(DirectoryPath) : MAX_PATH;
|
||||||
pFileSpecification = HeapAlloc(
|
pFileSpecification = MyMalloc(
|
||||||
GetProcessHeap(), 0,
|
|
||||||
(len + 1 + strlenW(InfFileSpecification) + 1) * sizeof(WCHAR));
|
(len + 1 + strlenW(InfFileSpecification) + 1) * sizeof(WCHAR));
|
||||||
if (!pFileSpecification)
|
if (!pFileSpecification)
|
||||||
{
|
{
|
||||||
|
@ -2017,7 +2016,7 @@ SetupGetInfFileListW(
|
||||||
hSearch = FindFirstFileW(pFileSpecification, &wfdFileInfo);
|
hSearch = FindFirstFileW(pFileSpecification, &wfdFileInfo);
|
||||||
if (hSearch == INVALID_HANDLE_VALUE)
|
if (hSearch == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, pFileSpecification);
|
TRACE("No file returned by %s\n", debugstr_w(pFileSpecification));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2053,10 +2052,12 @@ SetupGetInfFileListW(
|
||||||
} while (FindNextFileW(hSearch, &wfdFileInfo));
|
} while (FindNextFileW(hSearch, &wfdFileInfo));
|
||||||
FindClose(hSearch);
|
FindClose(hSearch);
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
requiredSize += sizeof(WCHAR); /* Final NULL char */
|
requiredSize += sizeof(WCHAR); /* Final NULL char */
|
||||||
if (requiredSize <= ReturnBufferSize)
|
if (requiredSize <= ReturnBufferSize)
|
||||||
|
{
|
||||||
*pBuffer = '\0';
|
*pBuffer = '\0';
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
|
@ -2066,7 +2067,7 @@ SetupGetInfFileListW(
|
||||||
*RequiredSize = requiredSize;
|
*RequiredSize = requiredSize;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
HeapFree(GetProcessHeap(), 0, pFileSpecification);
|
MyFree(pFileSpecification);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue