From 73c9bff8ccf7e22544d8c871d83653dd2878d102 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sun, 13 Dec 2009 16:05:15 +0000 Subject: [PATCH] [REG] - Fix a memory leak and bug in the deletion routine. If the buffer value_name was had been smaller than the longest key, then deletion of all values would have failed. - Fixed by Amine Khaldi [XCOPY] - Remove unnecessary assignment - By Amine Khaldi svn path=/trunk/; revision=44563 --- reactos/base/applications/cmdutils/reg/reg.c | 8 ++++++-- reactos/base/applications/cmdutils/xcopy/xcopy.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/reactos/base/applications/cmdutils/reg/reg.c b/reactos/base/applications/cmdutils/reg/reg.c index a538d819a4b..d18540ee6a7 100644 --- a/reactos/base/applications/cmdutils/reg/reg.c +++ b/reactos/base/applications/cmdutils/reg/reg.c @@ -295,20 +295,24 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty, return 1; } maxValue++; + szValue = HeapAlloc(GetProcessHeap(),0,maxValue*sizeof(WCHAR)); + if (!szValue) return 1; while (1) { count = maxValue; - rc = RegEnumValueW(subkey, 0, value_name, &count, NULL, NULL, NULL, NULL); + rc = RegEnumValueW(subkey, 0, szValue, &count, NULL, NULL, NULL, NULL); if (rc == ERROR_SUCCESS) { - rc = RegDeleteValueW(subkey,value_name); + rc = RegDeleteValueW(subkey,szValue); if (rc != ERROR_SUCCESS) break; } else break; } + + HeapFree(GetProcessHeap(), 0, szValue); if (rc != ERROR_SUCCESS) { /* FIXME delete failed */ diff --git a/reactos/base/applications/cmdutils/xcopy/xcopy.c b/reactos/base/applications/cmdutils/xcopy/xcopy.c index eaff10cdc0a..f996144d543 100644 --- a/reactos/base/applications/cmdutils/xcopy/xcopy.c +++ b/reactos/base/applications/cmdutils/xcopy/xcopy.c @@ -261,10 +261,10 @@ int wmain (int argc, WCHAR *argvW[]) WINE_TRACE("Destination : '%s'\n", wine_dbgstr_w(supplieddestination)); /* Extract required information from source specification */ - rc = XCOPY_ProcessSourceParm(suppliedsource, sourcestem, sourcespec, flags); + XCOPY_ProcessSourceParm(suppliedsource, sourcestem, sourcespec, flags); /* Extract required information from destination specification */ - rc = XCOPY_ProcessDestParm(supplieddestination, destinationstem, + XCOPY_ProcessDestParm(supplieddestination, destinationstem, destinationspec, sourcespec, flags); /* Trace out the resulting information */