mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:35:43 +00:00
[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 so that strings are captured, it would then be needed to free the allocated buffers. In addition, fix a buggy call to INF_GetData() -- should be instead INF_GetDataField() -- in AddSectionToCopyQueue(). svn path=/branches/setup_improvements/; revision=75516
This commit is contained in:
parent
aa110db3ea
commit
cf2571de6e
3 changed files with 119 additions and 52 deletions
|
@ -76,11 +76,17 @@ InstallDriver(
|
|||
&& !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver, &Context)
|
||||
&& !SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver, &Context))
|
||||
{
|
||||
INF_FreeData(ClassGuid);
|
||||
INF_FreeData(Driver);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!INF_GetDataField(&Context, 1, &ImagePath))
|
||||
{
|
||||
INF_FreeData(ClassGuid);
|
||||
INF_FreeData(Driver);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Prepare full driver path */
|
||||
dwValue = PathPrefix.MaximumLength + wcslen(ImagePath) * sizeof(WCHAR);
|
||||
|
@ -88,6 +94,9 @@ InstallDriver(
|
|||
if (!FullImagePath)
|
||||
{
|
||||
DPRINT1("RtlAllocateHeap() failed\n");
|
||||
INF_FreeData(ImagePath);
|
||||
INF_FreeData(ClassGuid);
|
||||
INF_FreeData(Driver);
|
||||
return FALSE;
|
||||
}
|
||||
RtlCopyMemory(FullImagePath, PathPrefix.Buffer, PathPrefix.MaximumLength);
|
||||
|
@ -103,6 +112,9 @@ InstallDriver(
|
|||
{
|
||||
DPRINT1("NtCreateKey('%wZ') failed with status 0x%08x\n", &StringU, Status);
|
||||
RtlFreeHeap(ProcessHeap, 0, FullImagePath);
|
||||
INF_FreeData(ImagePath);
|
||||
INF_FreeData(ClassGuid);
|
||||
INF_FreeData(Driver);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -110,38 +122,38 @@ InstallDriver(
|
|||
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 (ClassGuid &&_wcsicmp(ClassGuid, L"{4D36E96B-E325-11CE-BFC1-08002BE10318}") == 0)
|
||||
{
|
||||
|
@ -154,29 +166,32 @@ InstallDriver(
|
|||
(wcslen(keyboardClass) + 2) * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
INF_FreeData(ClassGuid);
|
||||
|
||||
/* 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;
|
||||
|
|
|
@ -324,6 +324,7 @@ CreateComputerTypeList(
|
|||
DPRINT("KeyValue: %S\n", KeyValue);
|
||||
if (wcsstr(ComputerIdentifier, KeyValue))
|
||||
{
|
||||
INF_FreeData(KeyValue);
|
||||
if (!INF_GetDataField(&Context, 0, &KeyName))
|
||||
{
|
||||
/* FIXME: Handle error! */
|
||||
|
@ -333,7 +334,9 @@ CreateComputerTypeList(
|
|||
|
||||
DPRINT("Computer key: %S\n", KeyName);
|
||||
wcscpy(ComputerKey, KeyName);
|
||||
INF_FreeData(KeyName);
|
||||
}
|
||||
INF_FreeData(KeyValue);
|
||||
} while (SetupFindNextLine(&Context, &Context));
|
||||
|
||||
List = CreateGenericList();
|
||||
|
@ -348,7 +351,7 @@ CreateComputerTypeList(
|
|||
|
||||
do
|
||||
{
|
||||
if (!INF_GetData (&Context, &KeyName, &KeyValue))
|
||||
if (!INF_GetData(&Context, &KeyName, &KeyValue))
|
||||
{
|
||||
/* FIXME: Handle error! */
|
||||
DPRINT("INF_GetData() failed\n");
|
||||
|
@ -364,10 +367,13 @@ CreateComputerTypeList(
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -579,6 +585,7 @@ CreateDisplayDriverList(
|
|||
DPRINT("KeyValue: %S\n", KeyValue);
|
||||
if (wcsstr(DisplayIdentifier, KeyValue))
|
||||
{
|
||||
INF_FreeData(KeyValue);
|
||||
if (!INF_GetDataField(&Context, 0, &KeyName))
|
||||
{
|
||||
/* FIXME: Handle error! */
|
||||
|
@ -588,7 +595,9 @@ CreateDisplayDriverList(
|
|||
|
||||
DPRINT("Display key: %S\n", KeyName);
|
||||
wcscpy(DisplayKey, KeyName);
|
||||
INF_FreeData(KeyName);
|
||||
}
|
||||
INF_FreeData(KeyValue);
|
||||
} while (SetupFindNextLine(&Context, &Context));
|
||||
|
||||
List = CreateGenericList();
|
||||
|
@ -612,6 +621,7 @@ CreateDisplayDriverList(
|
|||
if (!INF_GetDataField(&Context, 1, &KeyValue))
|
||||
{
|
||||
DPRINT1("INF_GetDataField() failed\n");
|
||||
INF_FreeData(KeyName);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -622,16 +632,19 @@ CreateDisplayDriverList(
|
|||
{
|
||||
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
|
||||
|
@ -1061,7 +1074,7 @@ CreateLanguageList(
|
|||
} 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);
|
||||
|
@ -1234,7 +1247,7 @@ SetGeoID(
|
|||
Status = NtOpenKey(&KeyHandle,
|
||||
KEY_SET_VALUE,
|
||||
&ObjectAttributes);
|
||||
if(!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtOpenKey() failed (Status %lx)\n", Status);
|
||||
return FALSE;
|
||||
|
|
|
@ -3718,13 +3718,20 @@ AddSectionToCopyQueueCab(HINF InfFile,
|
|||
{
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -3739,6 +3746,10 @@ AddSectionToCopyQueueCab(HINF InfFile,
|
|||
/* FIXME: Handle error! */
|
||||
DPRINT1("SetupQueueCopy() failed\n");
|
||||
}
|
||||
|
||||
INF_FreeData(FileKeyName);
|
||||
INF_FreeData(TargetFileName);
|
||||
INF_FreeData(DirKeyValue);
|
||||
} while (SetupFindNextLine(&FilesContext, &FilesContext));
|
||||
|
||||
return TRUE;
|
||||
|
@ -3782,8 +3793,8 @@ AddSectionToCopyQueue(HINF InfFile,
|
|||
*/
|
||||
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");
|
||||
|
@ -3795,6 +3806,7 @@ AddSectionToCopyQueue(HINF InfFile,
|
|||
{
|
||||
/* FIXME: Handle error! */
|
||||
DPRINT1("INF_GetData() failed\n");
|
||||
INF_FreeData(FileKeyName);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3811,13 +3823,20 @@ AddSectionToCopyQueue(HINF InfFile,
|
|||
{
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -3863,6 +3882,10 @@ AddSectionToCopyQueue(HINF InfFile,
|
|||
/* FIXME: Handle error! */
|
||||
DPRINT1("SetupQueueCopy() failed\n");
|
||||
}
|
||||
|
||||
INF_FreeData(FileKeyName);
|
||||
INF_FreeData(TargetFileName);
|
||||
INF_FreeData(DirKeyValue);
|
||||
} while (SetupFindNextLine(&FilesContext, &FilesContext));
|
||||
|
||||
return TRUE;
|
||||
|
@ -3968,6 +3991,7 @@ PrepareCopyPageInfFile(HINF InfFile,
|
|||
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;
|
||||
|
@ -3986,11 +4010,14 @@ PrepareCopyPageInfFile(HINF InfFile,
|
|||
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;
|
||||
|
@ -4380,7 +4407,12 @@ DoUpdate:
|
|||
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;
|
||||
|
@ -4389,14 +4421,21 @@ DoUpdate:
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue