From 173b42e7cb4085137f45a7d72cb4c4863ef3d313 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Fri, 3 Feb 2012 11:21:15 +0000 Subject: [PATCH] [SMSS2] - 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 --- reactos/base/system/smss2/sminit.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/reactos/base/system/smss2/sminit.c b/reactos/base/system/smss2/sminit.c index 77da15a2c3b..625de6a58be 100644 --- a/reactos/base/system/smss2/sminit.c +++ b/reactos/base/system/smss2/sminit.c @@ -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); }