mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
- Fix heap corruption and memory leak
- patch by Daniel Zimmermann - CID 707 - bug 3905 svn path=/trunk/; revision=37619
This commit is contained in:
parent
d8a4dde485
commit
21f2f21a4d
1 changed files with 10 additions and 5 deletions
|
@ -62,7 +62,7 @@ GetSystemDrive(WCHAR **szSystemDrive)
|
||||||
|
|
||||||
/* get Path to freeldr.ini or boot.ini */
|
/* get Path to freeldr.ini or boot.ini */
|
||||||
*szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
|
*szSystemDrive = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
|
||||||
if (szSystemDrive != NULL)
|
if (*szSystemDrive != NULL)
|
||||||
{
|
{
|
||||||
dwBufSize = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, MAX_PATH);
|
dwBufSize = GetEnvironmentVariableW(L"SystemDrive", *szSystemDrive, MAX_PATH);
|
||||||
if (dwBufSize > MAX_PATH)
|
if (dwBufSize > MAX_PATH)
|
||||||
|
@ -83,15 +83,15 @@ GetSystemDrive(WCHAR **szSystemDrive)
|
||||||
else if (dwBufSize == 0)
|
else if (dwBufSize == 0)
|
||||||
{
|
{
|
||||||
FailGetSysDrive:
|
FailGetSysDrive:
|
||||||
HeapFree(GetProcessHeap(), 0, szSystemDrive);
|
HeapFree(GetProcessHeap(), 0, *szSystemDrive);
|
||||||
*szSystemDrive = NULL;
|
*szSystemDrive = NULL;
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dwBufSize;
|
return dwBufSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PBOOTRECORD
|
static PBOOTRECORD
|
||||||
|
@ -454,7 +454,7 @@ LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
|
||||||
HINF hInf;
|
HINF hInf;
|
||||||
|
|
||||||
dwBufSize = GetSystemDrive(&szSystemDrive);
|
dwBufSize = GetSystemDrive(&szSystemDrive);
|
||||||
if (!dwBufSize)
|
if (dwBufSize == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
|
wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
|
||||||
|
@ -462,6 +462,8 @@ LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
|
||||||
|
|
||||||
if (PathFileExistsW(pStartInfo->szFreeldrIni))
|
if (PathFileExistsW(pStartInfo->szFreeldrIni))
|
||||||
{
|
{
|
||||||
|
/* free resource previously allocated by GetSystemDrive() */
|
||||||
|
HeapFree(GetProcessHeap(), 0, szSystemDrive);
|
||||||
/* freeldr.ini exists */
|
/* freeldr.ini exists */
|
||||||
hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
|
hInf = SetupOpenInfFileW(pStartInfo->szFreeldrIni,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -482,6 +484,9 @@ LoadOSList(HWND hwndDlg, PSTARTINFO pStartInfo)
|
||||||
wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
|
wcscpy(pStartInfo->szFreeldrIni, szSystemDrive);
|
||||||
wcscat(pStartInfo->szFreeldrIni, L"\\boot.ini");
|
wcscat(pStartInfo->szFreeldrIni, L"\\boot.ini");
|
||||||
|
|
||||||
|
/* free resource previously allocated by GetSystemDrive() */
|
||||||
|
HeapFree(GetProcessHeap(), 0, szSystemDrive);
|
||||||
|
|
||||||
if (PathFileExistsW(pStartInfo->szFreeldrIni))
|
if (PathFileExistsW(pStartInfo->szFreeldrIni))
|
||||||
{
|
{
|
||||||
/* load boot.ini settings */
|
/* load boot.ini settings */
|
||||||
|
|
Loading…
Reference in a new issue