mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[SETUPAPI] diskspace.c: Fix memory allocations.
- The allocated file element should use the CRT allocator, as it is how it gets freed in SetupDestroyDiskSpaceList (and SetupDuplicateDiskSpaceListW) - GetFullPathNameW() takes the buffer size in number of characters, not in bytes. Fix for wine-staging commit: setupapi: Implement SetupAddToDiskSpaceList. wine-staging patch by Michael Müller <michael@fds-team.de>
This commit is contained in:
parent
b023d5b821
commit
2788057a2d
1 changed files with 13 additions and 0 deletions
|
@ -527,8 +527,13 @@ BOOL WINAPI SetupAddToDiskSpaceListW(HDSKSPC diskspace, PCWSTR targetfile,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef __REACTOS__ // BUGFIX
|
||||
size++; // Add terminating NUL
|
||||
fullpathW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
|
||||
#else
|
||||
size = (size+1) * sizeof(WCHAR);
|
||||
fullpathW = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
#endif
|
||||
|
||||
if (!GetFullPathNameW(targetfile, size, fullpathW, NULL))
|
||||
{
|
||||
|
@ -551,7 +556,11 @@ BOOL WINAPI SetupAddToDiskSpaceListW(HDSKSPC diskspace, PCWSTR targetfile,
|
|||
|
||||
if (&file->entry == &list->files)
|
||||
{
|
||||
#ifdef __REACTOS__ // BUGFIX
|
||||
file = malloc(sizeof(*file));
|
||||
#else
|
||||
file = HeapAlloc(GetProcessHeap(), 0, sizeof(*file));
|
||||
#endif
|
||||
if (!file)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
|
@ -562,7 +571,11 @@ BOOL WINAPI SetupAddToDiskSpaceListW(HDSKSPC diskspace, PCWSTR targetfile,
|
|||
if (!file->path)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
#ifdef __REACTOS__ // BUGFIX
|
||||
free(file);
|
||||
#else
|
||||
HeapFree(GetProcessHeap(), 0, file);
|
||||
#endif
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue