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;
}
fixed a memory leak in RegDeleteTree() that could be caused when two
threads attempt to delete the same tree simultaneously
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 21:40:58 UTC
(rev 18253)
+++ trunk/reactos/lib/advapi32/reg/reg.c 2005-10-03 22:46:49 UTC
(rev 18254)
@@ -1466,7 +1466,15 @@
}
else if (Status2 == STATUS_NO_MORE_ENTRIES)
{
- ASSERT(newDelKeys == NULL);
+ /* in some race conditions where another thread
would delete
+ the same tree at the same time, newDelKeys could
actually
+ be != NULL! */
+ if (newDelKeys != NULL)
+ {
+ RtlFreeHeap(ProcessHeap,
+ 0,
+ newDelKeys);
+ }
break;
}
@@ -1555,7 +1563,7 @@
NULL);
Status = NtOpenKey(&SubKeyHandle,
- DELETE | KEY_ENUMERATE_SUB_KEYS |
KEY_QUERY_VALUE,
+ DELETE | KEY_ENUMERATE_SUB_KEYS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
A note about this piece of code.
Added: trunk/reactos/lib/nt/readme.txt
_____
Added: trunk/reactos/lib/nt/readme.txt
--- trunk/reactos/lib/nt/readme.txt 2005-10-03 21:37:05 UTC (rev
18252)
+++ trunk/reactos/lib/nt/readme.txt 2005-10-03 21:40:58 UTC (rev
18253)
@@ -0,0 +1,2 @@
+This is the startup code for NT native processes.
+(smss.exe, autochk.exe, csrss.exe)
Property changes on: trunk/reactos/lib/nt/readme.txt
___________________________________________________________________
Name: svn:eol-style
+ native
dont use the whole commandline as a fall back for execution searching
because it could contain spaces. also, wrap commandline params in
quotes so if there is a space in the path it still finds it. bug found
by billgMS.
Modified: trunk/reactos/subsys/system/cmd/cmd.c
_____
Modified: trunk/reactos/subsys/system/cmd/cmd.c
--- trunk/reactos/subsys/system/cmd/cmd.c 2005-10-03 18:49:44 UTC
(rev 18249)
+++ trunk/reactos/subsys/system/cmd/cmd.c 2005-10-03 20:28:29 UTC
(rev 18250)
@@ -423,15 +423,12 @@
/* search the PATH environment variable for the binary */
if (!SearchForExecutable (first, szFullName))
{
- if (!SearchForExecutable (full, szFullName))
- {
error_bad_command ();
free (first);
free (rest);
free (full);
free (szFullName);
return;
- }
}
@@ -1619,13 +1616,14 @@
++i;
if (i < argc)
{
- _tcscpy (commandline, argv[i]);
+ _tcscpy (commandline, _T("\""));
+ _tcscat (commandline, argv[i]);
+ _tcscat (commandline, _T("\""));
while (++i < argc)
{
_tcscat (commandline,
_T(" "));
_tcscat (commandline,
argv[i]);
}
-
ParseCommandLine(commandline);
}
}