don't leak memory in RegDeleteTree() when NtEnumerateKey() returns an unexpected error code (such as when there's insufficient system resources to perform the query)
Modified: trunk/reactos/lib/advapi32/reg/reg.c

Modified: trunk/reactos/lib/advapi32/reg/reg.c
--- trunk/reactos/lib/advapi32/reg/reg.c	2005-10-03 22:46:49 UTC (rev 18254)
+++ trunk/reactos/lib/advapi32/reg/reg.c	2005-10-03 23:01:10 UTC (rev 18255)
@@ -1479,14 +1479,18 @@
                 }
 
 SubKeyFailure:
-                ASSERT(newDelKeys != NULL);
-                RtlFreeHeap(ProcessHeap,
-                            0,
-                            newDelKeys);
+                /* newDelKeys can be NULL here when NtEnumerateKey returned an
+                   error other than STATUS_BUFFER_TOO_SMALL or STATUS_BUFFER_OVERFLOW! */
+                if (newDelKeys != NULL)
+                {
+                    RtlFreeHeap(ProcessHeap,
+                                0,
+                                newDelKeys);
+                }
 
 SubKeyFailureNoFree:
                 /* don't break, let's try to delete as many keys as possible */
-                if (Status2 != STATUS_NO_MORE_ENTRIES && NT_SUCCESS(Status))
+                if (NT_SUCCESS(Status))
                 {
                     Status = Status2;
                 }