From 25886dff5a94c16fb2c2ec4660ca3950dc77ccda Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 17 Oct 2005 23:38:24 +0000 Subject: [PATCH] fix some bugs in regedit like alloca -> HeapAlloc + HeapFree svn path=/trunk/; revision=18544 --- reactos/subsys/system/regedit/regproc.c | 19 ++++++++++++++----- reactos/subsys/system/regedit/security.c | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/reactos/subsys/system/regedit/regproc.c b/reactos/subsys/system/regedit/regproc.c index 17ab9ff9b23..662ed2df624 100644 --- a/reactos/subsys/system/regedit/regproc.c +++ b/reactos/subsys/system/regedit/regproc.c @@ -1620,17 +1620,26 @@ LONG RegRenameKey(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpNewName) { LPCTSTR s; LPTSTR lpNewSubKey; + LONG Ret = 0; s = _tcsrchr(lpSubKey, '\\'); if (s) { s++; - lpNewSubKey = (LPTSTR) alloca((s - lpSubKey + _tcslen(lpNewName) + 1) * sizeof(TCHAR)); - memcpy(lpNewSubKey, lpSubKey, (s - lpSubKey) * sizeof(TCHAR)); - _tcscpy(lpNewSubKey + (s - lpSubKey), lpNewName); - lpNewName = lpNewSubKey; + lpNewSubKey = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, (s - lpSubKey + _tcslen(lpNewName) + 1) * sizeof(TCHAR)); + if (lpNewName != NULL) { + memcpy(lpNewSubKey, lpSubKey, (s - lpSubKey) * sizeof(TCHAR)); + _tcscpy(lpNewSubKey + (s - lpSubKey), lpNewName); + lpNewName = lpNewSubKey; + } } - return RegMoveKey(hKey, lpNewName, hKey, lpSubKey); + if (lpNewName != NULL) { + Ret = RegMoveKey(hKey, lpNewName, hKey, lpSubKey); + if (s) { + HeapFree(GetProcessHeap(), 0, lpNewSubKey); + } + } + return Ret; } LONG RegRenameValue(HKEY hKey, LPCTSTR lpSubKey, LPCTSTR lpDestValue, LPCTSTR lpSrcValue) diff --git a/reactos/subsys/system/regedit/security.c b/reactos/subsys/system/regedit/security.c index ac54014b240..5a5108096f4 100644 --- a/reactos/subsys/system/regedit/security.c +++ b/reactos/subsys/system/regedit/security.c @@ -295,7 +295,7 @@ RegKeyEditPermissions(HWND hWndOwner, LPCTSTR lpMachine, LPCTSTR lpKeyName) { - BOOL Result; + BOOL Result = FALSE; LPWSTR Machine, KeyName; HKEY hInfoKey; LPREGKEYSECURITY RegKeySecurity;