improved error handling in RegRenameKey
Modified: trunk/reactos/subsys/system/regedit/regproc.c
_____
Modified: trunk/reactos/subsys/system/regedit/regproc.c
--- trunk/reactos/subsys/system/regedit/regproc.c 2005-10-20
18:07:00 UTC (rev 18641)
+++ trunk/reactos/subsys/system/regedit/regproc.c 2005-10-20
18:17:06 UTC (rev 18642)
@@ -1622,23 +1622,27 @@
LPTSTR lpNewSubKey = NULL;
LONG Ret = 0;
- s = _tcsrchr(lpSubKey, '\\');
+ s = _tcsrchr(lpSubKey, _T('\\'));
if (s)
{
s++;
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;
- }
+ if (lpNewSubKey != NULL)
+ {
+ memcpy(lpNewSubKey, lpSubKey, (s - lpSubKey) *
sizeof(TCHAR));
+ _tcscpy(lpNewSubKey + (s - lpSubKey), lpNewName);
+ lpNewName = lpNewSubKey;
+ }
+ else
+ return ERROR_NOT_ENOUGH_MEMORY;
}
- if (lpNewName != NULL) {
- Ret = RegMoveKey(hKey, lpNewName, hKey, lpSubKey);
- if (s) {
- HeapFree(GetProcessHeap(), 0, lpNewSubKey);
- }
- }
+
+ Ret = RegMoveKey(hKey, lpNewName, hKey, lpSubKey);
+
+ if (lpNewSubKey)
+ {
+ HeapFree(GetProcessHeap(), 0, lpNewSubKey);
+ }
return Ret;
}
Show replies by date