Author: hbelusca
Date: Wed Aug 9 20:24:24 2017
New Revision: 75516
URL:
http://svn.reactos.org/svn/reactos?rev=75516&view=rev
Log:
[USETUP]: Sprinkle some INF_FreeData() calls to balance the INF_GetData() /
INF_GetDataField() calls. They currently do nothing, since the getter functions don't
actually capture (copy) the strings but merely return pointers to read-only strings. But
the calls are placed here for consistency, because if one day the getters implementation
is changed to capture the strings, then it would now be needed to free the allocated
buffers.
In addition, fix a buggy call to INF_GetData() -- should be instead INF_GetDataField() --
in AddSectionToCopyQueue().
Modified:
branches/setup_improvements/base/setup/usetup/interface/devinst.c
branches/setup_improvements/base/setup/usetup/interface/usetup.c
branches/setup_improvements/base/setup/usetup/settings.c
Modified: branches/setup_improvements/base/setup/usetup/interface/devinst.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/interface/devinst.c [iso-8859-1]
(original)
+++ branches/setup_improvements/base/setup/usetup/interface/devinst.c [iso-8859-1] Wed Aug
9 20:24:24 2017
@@ -73,7 +73,10 @@
&& !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver,
&Context))
{
if (!SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver,
&Context))
+ {
+ INF_FreeData(Driver);
return FALSE;
+ }
keyboardDevice = TRUE;
}
@@ -87,6 +90,8 @@
if (!FullImagePath)
{
DPRINT1("RtlAllocateHeap() failed\n");
+ INF_FreeData(ImagePath);
+ INF_FreeData(Driver);
return FALSE;
}
RtlCopyMemory(FullImagePath, PathPrefix.Buffer, PathPrefix.MaximumLength);
@@ -102,6 +107,8 @@
{
DPRINT1("NtCreateKey('%wZ') failed with status 0x%08x\n",
&StringU, Status);
RtlFreeHeap(ProcessHeap, 0, FullImagePath);
+ INF_FreeData(ImagePath);
+ INF_FreeData(Driver);
return FALSE;
}
@@ -109,38 +116,38 @@
if (Disposition == REG_CREATED_NEW_KEY)
{
dwValue = 0;
- NtSetValueKey(
- hService,
- &ErrorControlU,
- 0,
- REG_DWORD,
- &dwValue,
- sizeof(dwValue));
+ NtSetValueKey(hService,
+ &ErrorControlU,
+ 0,
+ REG_DWORD,
+ &dwValue,
+ sizeof(dwValue));
+
dwValue = 0;
- NtSetValueKey(
- hService,
- &StartU,
- 0,
- REG_DWORD,
- &dwValue,
- sizeof(dwValue));
+ NtSetValueKey(hService,
+ &StartU,
+ 0,
+ REG_DWORD,
+ &dwValue,
+ sizeof(dwValue));
+
dwValue = SERVICE_KERNEL_DRIVER;
- NtSetValueKey(
- hService,
- &TypeU,
- 0,
- REG_DWORD,
- &dwValue,
- sizeof(dwValue));
+ NtSetValueKey(hService,
+ &TypeU,
+ 0,
+ REG_DWORD,
+ &dwValue,
+ sizeof(dwValue));
}
/* HACK: don't put any path in registry */
- NtSetValueKey(
- hService,
- &ImagePathU,
- 0,
- REG_SZ,
- ImagePath,
- (wcslen(ImagePath) + 1) * sizeof(WCHAR));
+ NtSetValueKey(hService,
+ &ImagePathU,
+ 0,
+ REG_SZ,
+ ImagePath,
+ (wcslen(ImagePath) + 1) * sizeof(WCHAR));
+
+ INF_FreeData(ImagePath);
if (keyboardDevice)
{
@@ -154,28 +161,29 @@
}
/* Associate device with the service we just filled */
- Status = NtSetValueKey(
- hDeviceKey,
- &ServiceU,
- 0,
- REG_SZ,
- Driver,
- (wcslen(Driver) + 1) * sizeof(WCHAR));
+ Status = NtSetValueKey(hDeviceKey,
+ &ServiceU,
+ 0,
+ REG_SZ,
+ Driver,
+ (wcslen(Driver) + 1) * sizeof(WCHAR));
if (NT_SUCCESS(Status))
{
/* Restart the device, so it will use the driver we registered */
deviceInstalled = ResetDevice(DeviceId);
}
+ INF_FreeData(Driver);
+
/* HACK: Update driver path */
- NtSetValueKey(
- hService,
- &ImagePathU,
- 0,
- REG_SZ,
- FullImagePath,
- (wcslen(FullImagePath) + 1) * sizeof(WCHAR));
+ NtSetValueKey(hService,
+ &ImagePathU,
+ 0,
+ REG_SZ,
+ FullImagePath,
+ (wcslen(FullImagePath) + 1) * sizeof(WCHAR));
RtlFreeHeap(ProcessHeap, 0, FullImagePath);
+
NtClose(hService);
return deviceInstalled;
Modified: branches/setup_improvements/base/setup/usetup/interface/usetup.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1]
(original)
+++ branches/setup_improvements/base/setup/usetup/interface/usetup.c [iso-8859-1] Wed Aug
9 20:24:24 2017
@@ -3545,13 +3545,20 @@
{
/* FIXME: Handle error! */
DPRINT1("SetupFindFirstLine() failed\n");
+ INF_FreeData(FileKeyName);
+ INF_FreeData(FileKeyValue);
+ INF_FreeData(TargetFileName);
break;
}
+
+ INF_FreeData(FileKeyValue);
if (!INF_GetData(&DirContext, NULL, &DirKeyValue))
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
+ INF_FreeData(FileKeyName);
+ INF_FreeData(TargetFileName);
break;
}
@@ -3566,6 +3573,10 @@
/* FIXME: Handle error! */
DPRINT1("SetupQueueCopy() failed\n");
}
+
+ INF_FreeData(FileKeyName);
+ INF_FreeData(TargetFileName);
+ INF_FreeData(DirKeyValue);
} while (SetupFindNextLine(&FilesContext, &FilesContext));
return TRUE;
@@ -3609,8 +3620,8 @@
*/
do
{
- /* Get source file name and target directory id */
- if (!INF_GetData(&FilesContext, &FileKeyName, &FileKeyValue))
+ /* Get source file name */
+ if (!INF_GetDataField(&FilesContext, 0, &FileKeyName))
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
@@ -3622,6 +3633,7 @@
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
+ INF_FreeData(FileKeyName);
break;
}
@@ -3638,13 +3650,20 @@
{
/* FIXME: Handle error! */
DPRINT1("SetupFindFirstLine() failed\n");
+ INF_FreeData(FileKeyName);
+ INF_FreeData(FileKeyValue);
+ INF_FreeData(TargetFileName);
break;
}
+
+ INF_FreeData(FileKeyValue);
if (!INF_GetData(&DirContext, NULL, &DirKeyValue))
{
/* FIXME: Handle error! */
DPRINT1("INF_GetData() failed\n");
+ INF_FreeData(FileKeyName);
+ INF_FreeData(TargetFileName);
break;
}
@@ -3690,6 +3709,10 @@
/* FIXME: Handle error! */
DPRINT1("SetupQueueCopy() failed\n");
}
+
+ INF_FreeData(FileKeyName);
+ INF_FreeData(TargetFileName);
+ INF_FreeData(DirKeyValue);
} while (SetupFindNextLine(&FilesContext, &FilesContext));
return TRUE;
@@ -3795,6 +3818,7 @@
Status = SetupCreateDirectory(PathBuffer);
if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
{
+ INF_FreeData(DirKeyValue);
DPRINT("Creating directory '%S' failed: Status =
0x%08lx", PathBuffer, Status);
MUIDisplayError(ERROR_CREATE_DIR, Ir, POPUP_WAIT_ENTER);
return FALSE;
@@ -3813,11 +3837,14 @@
Status = SetupCreateDirectory(PathBuffer);
if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_NAME_COLLISION)
{
+ INF_FreeData(DirKeyValue);
DPRINT("Creating directory '%S' failed: Status =
0x%08lx", PathBuffer, Status);
MUIDisplayError(ERROR_CREATE_DIR, Ir, POPUP_WAIT_ENTER);
return FALSE;
}
}
+
+ INF_FreeData(DirKeyValue);
} while (SetupFindNextLine(&DirContext, &DirContext));
return TRUE;
@@ -4209,7 +4236,12 @@
DPRINT("Action: %S File: %S Section %S\n", Action, File, Section);
if (Action == NULL)
+ {
+ INF_FreeData(Action);
+ INF_FreeData(File);
+ INF_FreeData(Section);
break; // Hackfix
+ }
if (!_wcsicmp(Action, L"AddReg"))
Delete = FALSE;
@@ -4218,14 +4250,21 @@
else
{
DPRINT1("Unrecognized registry INF action '%S'\n",
Action);
+ INF_FreeData(Action);
+ INF_FreeData(File);
+ INF_FreeData(Section);
continue;
}
+ INF_FreeData(Action);
+
CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE), File);
if (!ImportRegistryFile(SourcePath.Buffer, File, Section, LanguageId, Delete))
{
DPRINT1("Importing %S failed\n", File);
+ INF_FreeData(File);
+ INF_FreeData(Section);
MUIDisplayError(ERROR_IMPORT_HIVE, Ir, POPUP_WAIT_ENTER);
goto Cleanup;
}
Modified: branches/setup_improvements/base/setup/usetup/settings.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
==============================================================================
--- branches/setup_improvements/base/setup/usetup/settings.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/setup/usetup/settings.c [iso-8859-1] Wed Aug 9
20:24:24 2017
@@ -325,6 +325,7 @@
DPRINT("KeyValue: %S\n", KeyValue);
if (wcsstr(ComputerIdentifier, KeyValue))
{
+ INF_FreeData(KeyValue);
if (!INF_GetDataField(&Context, 0, &KeyName))
{
/* FIXME: Handle error! */
@@ -334,7 +335,9 @@
DPRINT("Computer key: %S\n", KeyName);
wcscpy(ComputerKey, KeyName);
- }
+ INF_FreeData(KeyName);
+ }
+ INF_FreeData(KeyValue);
} while (SetupFindNextLine(&Context, &Context));
List = CreateGenericList();
@@ -349,7 +352,7 @@
do
{
- if (!INF_GetData (&Context, &KeyName, &KeyValue))
+ if (!INF_GetData(&Context, &KeyName, &KeyValue))
{
/* FIXME: Handle error! */
DPRINT("INF_GetData() failed\n");
@@ -365,10 +368,13 @@
}
wcscpy(UserData, KeyName);
+ INF_FreeData(KeyName);
sprintf(Buffer, "%S", KeyValue);
+ INF_FreeData(KeyValue);
+
AppendGenericListEntry(List, Buffer, UserData,
- _wcsicmp(KeyName, ComputerKey) ? FALSE : TRUE);
+ _wcsicmp(UserData, ComputerKey) ? FALSE : TRUE);
} while (SetupFindNextLine(&Context, &Context));
return List;
@@ -580,6 +586,7 @@
DPRINT("KeyValue: %S\n", KeyValue);
if (wcsstr(DisplayIdentifier, KeyValue))
{
+ INF_FreeData(KeyValue);
if (!INF_GetDataField(&Context, 0, &KeyName))
{
/* FIXME: Handle error! */
@@ -589,7 +596,9 @@
DPRINT("Display key: %S\n", KeyName);
wcscpy(DisplayKey, KeyName);
- }
+ INF_FreeData(KeyName);
+ }
+ INF_FreeData(KeyValue);
} while (SetupFindNextLine(&Context, &Context));
List = CreateGenericList();
@@ -613,6 +622,7 @@
if (!INF_GetDataField(&Context, 1, &KeyValue))
{
DPRINT1("INF_GetDataField() failed\n");
+ INF_FreeData(KeyName);
break;
}
@@ -623,16 +633,19 @@
{
DPRINT1("RtlAllocateHeap() failed\n");
DestroyGenericList(List, TRUE);
+ INF_FreeData(KeyValue);
+ INF_FreeData(KeyName);
return NULL;
}
wcscpy(UserData, KeyName);
+ INF_FreeData(KeyName);
sprintf(Buffer, "%S", KeyValue);
- AppendGenericListEntry(List,
- Buffer,
- UserData,
- _wcsicmp(KeyName, DisplayKey) ? FALSE : TRUE);
+ INF_FreeData(KeyValue);
+
+ AppendGenericListEntry(List, Buffer, UserData,
+ _wcsicmp(UserData, DisplayKey) ? FALSE : TRUE);
} while (SetupFindNextLine(&Context, &Context));
#if 0
@@ -1062,7 +1075,7 @@
} while (SetupFindNextLine(&Context, &Context));
/* Only one language available, make it the default one */
- if(uIndex == 1 && UserData != NULL)
+ if (uIndex == 1 && UserData != NULL)
{
DefaultLanguageIndex = 0;
wcscpy(DefaultLanguage, UserData);
@@ -1235,7 +1248,7 @@
Status = NtOpenKey(&KeyHandle,
KEY_SET_VALUE,
&ObjectAttributes);
- if(!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
return FALSE;