- Properly handle an empty list in SmpSaveRegistryValue
- Compare the value string for equality, as the comment says, not inequality
- This fixes a crash, although another solution may perhaps be better

svn path=/trunk/; revision=55391
This commit is contained in:
Thomas Faber
2012-02-03 11:21:15 +00:00
parent 4895b9388e
commit 173b42e7cb
+6 -9
View File
@@ -72,7 +72,10 @@ SmpSaveRegistryValue(IN PLIST_ENTRY ListAddress,
RtlInitUnicodeString(&NameString, Name);
RtlInitUnicodeString(&ValueString, Value);
/* Check if we should do a duplicat echeck */
/* In case this is the first value, initialize a new list/structure */
RegEntry = NULL;
/* Check if we should do a duplicate check */
if (Flags)
{
/* Loop the current list */
@@ -86,9 +89,7 @@ SmpSaveRegistryValue(IN PLIST_ENTRY ListAddress,
if (!RtlCompareUnicodeString(&RegEntry->Name, &NameString, TRUE))
{
/* Check if the value is the exact same thing */
if (((Value) &&
(RtlCompareUnicodeString(&RegEntry->Value, &ValueString, TRUE))) ||
(!(Value) && !(RegEntry->Value.Buffer)))
if (!RtlCompareUnicodeString(&RegEntry->Value, &ValueString, TRUE))
{
/* Fail -- the same setting is being set twice */
return STATUS_OBJECT_NAME_EXISTS;
@@ -103,11 +104,6 @@ SmpSaveRegistryValue(IN PLIST_ENTRY ListAddress,
RegEntry = NULL;
}
}
else
{
/* This should be the first value, so initialize a new list/structure */
RegEntry = NULL;
}
/* Are we adding on, or creating a new entry */
if (!RegEntry)
@@ -140,6 +136,7 @@ SmpSaveRegistryValue(IN PLIST_ENTRY ListAddress,
if (RegEntry->Value.Buffer)
{
/* Free it */
ASSERT(RegEntry->Value.Length != 0);
RtlFreeHeap(RtlGetProcessHeap(), 0, RegEntry->Value.Buffer);
}