Author: pschweitzer Date: Thu Oct 6 21:36:10 2011 New Revision: 54034
URL: http://svn.reactos.org/svn/reactos?rev=54034&view=rev Log: [REGEXPL] Fix memory leaks Fix broken if condition Use delete[] operator for allocations made with new[] operator Properly check for failed allocations by not throwing exception
Modified: trunk/rosapps/applications/sysutils/regexpl/Completion.cpp trunk/rosapps/applications/sysutils/regexpl/Console.cpp trunk/rosapps/applications/sysutils/regexpl/Prompt.cpp trunk/rosapps/applications/sysutils/regexpl/RegistryExplorer.cpp trunk/rosapps/applications/sysutils/regexpl/RegistryKey.cpp trunk/rosapps/applications/sysutils/regexpl/RegistryTree.cpp trunk/rosapps/applications/sysutils/regexpl/Settings.cpp trunk/rosapps/applications/sysutils/regexpl/ShellCommandDACL.cpp trunk/rosapps/applications/sysutils/regexpl/ShellCommandDeleteValue.cpp trunk/rosapps/applications/sysutils/regexpl/ShellCommandDir.cpp trunk/rosapps/applications/sysutils/regexpl/ShellCommandSACL.cpp trunk/rosapps/applications/sysutils/regexpl/ShellCommandSetValue.cpp trunk/rosapps/applications/sysutils/regexpl/ShellCommandValue.cpp trunk/rosapps/applications/sysutils/regexpl/ShellCommandsLinkedList.cpp trunk/rosapps/applications/sysutils/regexpl/TextHistory.cpp trunk/rosapps/applications/sysutils/regexpl/ph.h
Modified: trunk/rosapps/applications/sysutils/regexpl/Completion.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/Completion.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/Completion.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -49,9 +49,9 @@ size_t s = _tcslen(pszText);
if (m_pszText) - delete m_pszText; - - m_pszText = new TCHAR [s+(b?3:1)]; // if we have spaces in unique part, we need 2 addtional chars for " + delete[] m_pszText; + + m_pszText = new (std::nothrow) TCHAR [s+(b?3:1)]; // if we have spaces in unique part, we need 2 addtional chars for "
if (!m_pszText) return FALSE; @@ -75,7 +75,7 @@ ~CCompletionMatch() { if (m_pszText) - delete m_pszText; + delete[] m_pszText; }
private: @@ -129,20 +129,20 @@ DeleteList();
if (m_pszContext) - delete m_pszContext; + delete[] m_pszContext;
if (m_pszBegin) - delete m_pszBegin; + delete[] m_pszBegin;
if (m_pszCurrentKey) - delete m_pszCurrentKey; + delete[] m_pszCurrentKey; }
void CCompletionList::Invalidate() { if (m_pszCurrentKey) { - delete m_pszCurrentKey; + delete[] m_pszCurrentKey; m_pszCurrentKey = NULL; } } @@ -161,38 +161,48 @@ rblnNew = TRUE; if (m_pszContext) { - delete m_pszContext; + delete[] m_pszContext; m_pszContext = NULL; }
if (m_pszBegin) { - delete m_pszBegin; + delete[] m_pszBegin; m_pszBegin = NULL; }
if (m_pszCurrentKey) { - delete m_pszCurrentKey; + delete[] m_pszCurrentKey; m_pszCurrentKey = NULL; }
size_t s = _tcslen(pszContext); - m_pszContext = new TCHAR[s+1]; + m_pszContext = new (std::nothrow) TCHAR[s+1]; if (!m_pszContext) return FALSE; _tcscpy(m_pszContext,pszContext);
s = _tcslen(pszBegin); - m_pszBegin = new TCHAR[s+1]; + m_pszBegin = new (std::nothrow) TCHAR[s+1]; if (!m_pszBegin) + { + delete[] m_pszContext; + m_pszContext = NULL; return FALSE; + } _tcscpy(m_pszBegin,pszBegin);
s = _tcslen(pszCurrentKey); - m_pszCurrentKey = new TCHAR[s+1]; + m_pszCurrentKey = new (std::nothrow) TCHAR[s+1]; if (!m_pszCurrentKey) + { + delete[] m_pszContext; + delete[] m_pszBegin; + m_pszContext = NULL; + m_pszBegin = NULL; return FALSE; + } _tcscpy(m_pszCurrentKey,pszCurrentKey);
return TRUE; @@ -206,7 +216,7 @@ { if (_tcsnicmp(pszText,m_pszBegin,_tcslen(m_pszBegin)) != 0) return TRUE; - CCompletionMatch *pNode = new CCompletionMatch; + CCompletionMatch *pNode = new (std::nothrow) CCompletionMatch; if (!pNode) return FALSE; if (!pNode->Init(pszText)) @@ -363,7 +373,7 @@ if (nError != ERROR_SUCCESS) return FALSE;
- pszSubkeyName = new TCHAR[nKeyNameSize+dwMaxSubkeyNameLength+1]; + pszSubkeyName = new (std::nothrow) TCHAR[nKeyNameSize+dwMaxSubkeyNameLength+1]; if (!pszSubkeyName) goto Abort;
@@ -393,7 +403,7 @@ goto Abort; }
- pszValueName = new TCHAR[nKeyNameSize+dwMaxValueNameSize+1]; + pszValueName = new (std::nothrow) TCHAR[nKeyNameSize+dwMaxValueNameSize+1]; if (!pszValueName) goto Abort;
@@ -415,15 +425,15 @@ }
if (pszValueName) - delete pszValueName; + delete[] pszValueName; if (pszSubkeyName) - delete pszSubkeyName; + delete[] pszSubkeyName; return TRUE; Abort: if (pszValueName) - delete pszValueName; + delete[] pszValueName; if (pszSubkeyName) - delete pszSubkeyName; + delete[] pszSubkeyName; return FALSE; }
Modified: trunk/rosapps/applications/sysutils/regexpl/Console.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/Console.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/Console.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -71,11 +71,11 @@ CConsole::~CConsole() { if (m_pchBuffer) - delete m_pchBuffer; + delete[] m_pchBuffer; if (m_pchBuffer1) - delete m_pchBuffer1; + delete[] m_pchBuffer1; if (m_pchBuffer2) - delete m_pchBuffer2; + delete[] m_pchBuffer2;
if (m_blnOldInputModeSaved) SetConsoleMode(m_hStdIn,m_dwOldInputMode); @@ -946,15 +946,15 @@ if (m_pchBuffer2) delete m_pchBuffer2; m_pchBuffer2 = NULL;
- m_pchBuffer = new TCHAR [dwBufferSize]; + m_pchBuffer = new (std::nothrow) TCHAR [dwBufferSize]; if (!m_pchBuffer) goto Abort; m_pchBuffer[dwBufferSize-1] = 0;
- m_pchBuffer1 = new TCHAR [dwBufferSize]; + m_pchBuffer1 = new (std::nothrow) TCHAR [dwBufferSize]; if (!m_pchBuffer1) goto Abort; m_pchBuffer1[dwBufferSize-1] = 0;
- m_pchBuffer2 = new TCHAR [dwBufferSize]; + m_pchBuffer2 = new (std::nothrow) TCHAR [dwBufferSize]; if (!m_pchBuffer2) goto Abort; m_pchBuffer2[dwBufferSize-1] = 0;
@@ -972,13 +972,13 @@ if (m_hStdOut != INVALID_HANDLE_VALUE) VERIFY(CloseHandle(m_hStdOut)); m_hStdOut = INVALID_HANDLE_VALUE;
- if (m_pchBuffer) delete m_pchBuffer; + if (m_pchBuffer) delete[] m_pchBuffer; m_pchBuffer = NULL;
- if (m_pchBuffer1) delete m_pchBuffer1; + if (m_pchBuffer1) delete[] m_pchBuffer1; m_pchBuffer1 = NULL;
- if (m_pchBuffer2) delete m_pchBuffer2; + if (m_pchBuffer2) delete[] m_pchBuffer2; m_pchBuffer2 = NULL;
m_dwBufferSize = 0;
Modified: trunk/rosapps/applications/sysutils/regexpl/Prompt.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/Prompt.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/Prompt.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -32,7 +32,7 @@
CPrompt::CPrompt(CRegistryTree& rTree, HRESULT& rhr):m_rTree(rTree) { - m_pszPrompt = new TCHAR[_tcslen(DEFAULT_PROMPT)+1]; + m_pszPrompt = new (std::nothrow) TCHAR[_tcslen(DEFAULT_PROMPT)+1]; if (!m_pszPrompt) { rhr = E_OUTOFMEMORY; @@ -50,7 +50,7 @@ return E_UNEXPECTED; }
- m_pszPrompt = new TCHAR[_tcslen(pszPrompt)+1]; + m_pszPrompt = new (std::nothrow) TCHAR[_tcslen(pszPrompt)+1]; if (!m_pszPrompt) return E_OUTOFMEMORY;
@@ -62,7 +62,7 @@ CPrompt::~CPrompt() { if (m_pszPrompt) - delete m_pszPrompt; + delete[] m_pszPrompt; }
void CPrompt::ShowPrompt(CConsole &rConsole)
Modified: trunk/rosapps/applications/sysutils/regexpl/RegistryExplorer.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/RegistryExplorer.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/RegistryExplorer.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -138,7 +138,7 @@
CArgumentParser Parser;
- pSettings = new CSettings(); + pSettings = new (std::nothrow) CSettings(); if (!pSettings) { _ftprintf(stderr,_T("Cannot initialize settings. Out of memory.\n")); @@ -152,7 +152,7 @@ goto Abort; }
- pPrompt = new CPrompt(Tree,hr); + pPrompt = new (std::nothrow) CPrompt(Tree,hr); if (!pPrompt) { _ftprintf(stderr,_T("Cannot initialize prompt. Out of memory.\n"));
Modified: trunk/rosapps/applications/sysutils/regexpl/RegistryKey.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/RegistryKey.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/RegistryKey.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -70,7 +70,7 @@ { // copy machine name size_t size = _tcslen(pszMachineName);
- m_pszMachineName = new TCHAR [size+2]; + m_pszMachineName = new (std::nothrow) TCHAR [size+2]; if (!m_pszMachineName) return E_OUTOFMEMORY; _tcscpy(m_pszMachineName,pszMachineName); @@ -103,7 +103,7 @@ if (pszPath) size += _tcslen(pszPath);
- m_pszKeyName = new TCHAR [size+2]; + m_pszKeyName = new (std::nothrow) TCHAR [size+2]; if (!m_pszKeyName) return E_OUTOFMEMORY; _stprintf(m_pszKeyName,_T("%s%s\"),pszPath?pszPath:_T(""),pszKeyName); @@ -273,7 +273,7 @@ { const TCHAR *pszKeyName = GetKeyName(); size_t size = _tcslen(pszKeyName) + _tcslen(pszSubkeyName) + 1; - TCHAR *pszSubkeyFullName = new TCHAR [size]; + TCHAR *pszSubkeyFullName = new (std::nothrow) TCHAR [size]; if (!pszSubkeyFullName) { nError = RegCloseKey(hKey); @@ -283,7 +283,7 @@ _tcscpy(pszSubkeyFullName,pszKeyName); _tcscat(pszSubkeyFullName,pszSubkeyName); HRESULT hr = rKey.Init(hKey,GetKeyName(),pszSubkeyName,samDesired); - delete pszSubkeyName; + delete[] pszSubkeyName; if (FAILED(hr)) { nError = RegCloseKey(hKey);
Modified: trunk/rosapps/applications/sysutils/regexpl/RegistryTree.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/RegistryTree.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/RegistryTree.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -64,7 +64,7 @@ CRegistryTree::~CRegistryTree() { if (m_pszMachineName) - delete m_pszMachineName; + delete[] m_pszMachineName;
CNode *pNode; while(m_pCurrentKey->m_pUp) @@ -98,7 +98,7 @@ const TCHAR *pszSeps = _T("\");
// Make buffer and copy relative path into it. - TCHAR *pszBuffer = new TCHAR[_tcslen(pszRelativePath)+1]; + TCHAR *pszBuffer = new (std::nothrow) TCHAR[_tcslen(pszRelativePath)+1]; if (!pszBuffer) { SetError(ERROR_OUTOFMEMORY); @@ -145,7 +145,7 @@ return TRUE;
Abort: - delete pszBuffer; + delete[] pszBuffer; return FALSE; }
@@ -179,7 +179,7 @@ { // Delete previous machine name buffer if allocated. if (m_pszMachineName) - delete m_pszMachineName; + delete[] m_pszMachineName;
m_pszMachineName = NULL; m_Root.m_Key.InitRoot(); @@ -192,9 +192,9 @@
ASSERT(*pszMachineName); // No machine name.
- TCHAR *pszNewMachineName = new TCHAR[_tcslen(pszMachineName)+3]; // two leading backslashes + terminating null - - if (!pszMachineName) + TCHAR *pszNewMachineName = new (std::nothrow) TCHAR[_tcslen(pszMachineName)+3]; // two leading backslashes + terminating null + + if (!pszNewMachineName) { SetError(ERROR_OUTOFMEMORY); return FALSE; @@ -202,7 +202,7 @@
// Delete previous machine name buffer if allocated. if (m_pszMachineName) - delete m_pszMachineName; + delete[] m_pszMachineName;
m_pszMachineName = pszNewMachineName;
@@ -283,7 +283,7 @@ return FALSE; }
- TCHAR *pszSubkeyName = new TCHAR [dwMaxSubkeyNameLength]; + TCHAR *pszSubkeyName = new (std::nothrow) TCHAR [dwMaxSubkeyNameLength]; rKey.InitSubkeyEnumeration(pszSubkeyName, dwMaxSubkeyNameLength); BOOL blnKeyDeleted = FALSE; while ((nError = rKey.GetNextSubkeyName()) == ERROR_SUCCESS) @@ -393,7 +393,7 @@ BOOL CRegistryTree::InternalChangeCurrentKey(const TCHAR *pszSubkeyName, REGSAM DesiredAccess) { size_t size = _tcslen(pszSubkeyName); - TCHAR *pszSubkeyNameBuffer = new TCHAR[size+3]; + TCHAR *pszSubkeyNameBuffer = new (std::nothrow) TCHAR[size+3]; if (!pszSubkeyNameBuffer) { SetError(_T("Cannot open key : %s%s\nError %d (%s)\n"), @@ -409,7 +409,7 @@
if (_tcscmp(pszSubkeyName,_T(".")) == 0) { - delete pszSubkeyNameBuffer; + delete[] pszSubkeyNameBuffer; return TRUE; }
@@ -421,7 +421,7 @@ // We are on root ASSERT(m_pCurrentKey->m_pUp == NULL); SetError(_T("Cannot open key. The root is not child.\n")); - delete pszSubkeyNameBuffer; + delete[] pszSubkeyNameBuffer; return FALSE; }
@@ -429,13 +429,13 @@ if (!m_pCurrentKey->m_pUp) { SetInternalError(); - delete pszSubkeyNameBuffer; + delete[] pszSubkeyNameBuffer; return FALSE; } CNode *pNode = m_pCurrentKey; m_pCurrentKey = m_pCurrentKey->m_pUp; delete pNode; - delete pszSubkeyNameBuffer; + delete[] pszSubkeyNameBuffer; return TRUE; }
@@ -444,20 +444,20 @@ { SetError(_T("Cannot open key : %s%s\nError %d (%s)\n"), GetCurrentPath(),pszSubkeyName,ERROR_OUTOFMEMORY,GetErrorDescription(ERROR_OUTOFMEMORY)); - delete pszSubkeyNameBuffer; + delete[] pszSubkeyNameBuffer; return FALSE; }
if (!InternalGetSubkey(pszSubkeyName,DesiredAccess,pNewKey->m_Key)) { delete pNewKey; - delete pszSubkeyNameBuffer; + delete[] pszSubkeyNameBuffer; return FALSE; } pNewKey->m_pUp = m_pCurrentKey; m_pCurrentKey = pNewKey;
- delete pszSubkeyNameBuffer; + delete[] pszSubkeyNameBuffer; return TRUE; }
@@ -483,7 +483,7 @@ if (nError != ERROR_SUCCESS) goto SkipCaseUpdate;
- pszSubkeyNameCaseUpdated = new TCHAR [dwMaxSubkeyNameLength]; + pszSubkeyNameCaseUpdated = new (std::nothrow) TCHAR [dwMaxSubkeyNameLength]; m_pCurrentKey->m_Key.InitSubkeyEnumeration(pszSubkeyNameCaseUpdated, dwMaxSubkeyNameLength); while ((nError = m_pCurrentKey->m_Key.GetNextSubkeyName()) == ERROR_SUCCESS) if (_tcsicmp(pszSubkeyNameCaseUpdated, pszSubkeyName) == 0) @@ -491,7 +491,7 @@
if (nError != ERROR_SUCCESS) { - delete pszSubkeyNameCaseUpdated; + delete[] pszSubkeyNameCaseUpdated; pszSubkeyNameCaseUpdated = NULL; }
@@ -513,7 +513,7 @@ goto Abort; }
- delete pszSubkeyNameCaseUpdated; + delete[] pszSubkeyNameCaseUpdated; } else { @@ -535,7 +535,7 @@ return TRUE; Abort: if (pszSubkeyNameCaseUpdated) - delete pszSubkeyNameCaseUpdated; + delete[] pszSubkeyNameCaseUpdated;
if (hNewKey) { @@ -611,7 +611,7 @@ return FALSE; }
- TCHAR *pszShortKeyName = new TCHAR [size+1]; + TCHAR *pszShortKeyName = new (std::nothrow) TCHAR [size+1]; if (!pszShortKeyName) { SetError(ERROR_OUTOFMEMORY); @@ -624,6 +624,7 @@ // change to parent key if (!Tree.InternalChangeCurrentKey(_T(".."),READ_CONTROL)) { + delete[] pszShortKeyName; ASSERT(FALSE); SetInternalError(); return FALSE; @@ -632,10 +633,12 @@ // change back to target key if (!Tree.InternalGetSubkey(pszShortKeyName,DesiredAccess,rKey)) { + delete[] pszShortKeyName; SetError(Tree.GetLastErrorDescription()); return FALSE; }
+ delete[] pszShortKeyName; return TRUE; }
Modified: trunk/rosapps/applications/sysutils/regexpl/Settings.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/Settings.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/Settings.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -47,7 +47,7 @@ { if (m_pszPrompt) { - delete m_pszPrompt; + delete[] m_pszPrompt; m_pszPrompt = NULL; }
@@ -75,7 +75,7 @@ nError = RegQueryValueEx(hKey,PROMPT_VALUE_NAME,NULL,&dwType,NULL,&dwSize); if (nError == ERROR_SUCCESS && dwType == REG_SZ) { - m_pszPrompt = (TCHAR *) new BYTE[dwSize]; + m_pszPrompt = (TCHAR *) new (std::nothrow) BYTE[dwSize]; if (!m_pszPrompt) { hr = E_OUTOFMEMORY;
Modified: trunk/rosapps/applications/sysutils/regexpl/ShellCommandDACL.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/ShellCommandDACL.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/ShellCommandDACL.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -226,7 +226,7 @@ rConsole.Write(pchSID); rConsole.Write(_T("\n")); } - delete pchSID; + delete[] pchSID; DWORD dwNameBufferLength, dwDomainNameBufferLength; dwNameBufferLength = 1024; dwDomainNameBufferLength = 1024;
Modified: trunk/rosapps/applications/sysutils/regexpl/ShellCommandDeleteValue.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/ShellCommandDeleteValue.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/ShellCommandDeleteValue.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -147,7 +147,7 @@ return 0; }
- TCHAR *pszValueName = new TCHAR[dwMaxValueNameLength]; + TCHAR *pszValueName = new (std::nothrow) TCHAR[dwMaxValueNameLength]; if (!pszValueName) { rConsole.Write("Out of memory.");
Modified: trunk/rosapps/applications/sysutils/regexpl/ShellCommandDir.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/ShellCommandDir.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/ShellCommandDir.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -200,7 +200,7 @@ if (nError != ERROR_SUCCESS) throw nError;
- TCHAR *pszSubkeyNameBuffer = new TCHAR[dwMaxSubkeyNameLength]; + TCHAR *pszSubkeyNameBuffer = new (std::nothrow) TCHAR[dwMaxSubkeyNameLength]; if (!pszSubkeyNameBuffer) throw ERROR_OUTOFMEMORY;
@@ -216,7 +216,7 @@ } }
- delete pszSubkeyNameBuffer; + delete[] pszSubkeyNameBuffer;
if (nError != ERROR_NO_MORE_ITEMS) throw nError; @@ -226,7 +226,7 @@ if (nError != ERROR_SUCCESS) throw nError;
- TCHAR *pchValueNameBuffer = new TCHAR[dwMaxValueNameBufferSize]; + TCHAR *pchValueNameBuffer = new (std::nothrow) TCHAR[dwMaxValueNameBufferSize]; if (!pchValueNameBuffer) throw ERROR_OUTOFMEMORY;
@@ -259,7 +259,7 @@ } }
- delete pchValueNameBuffer; + delete[] pchValueNameBuffer;
if (nError != ERROR_NO_MORE_ITEMS) throw nError;
Modified: trunk/rosapps/applications/sysutils/regexpl/ShellCommandSACL.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/ShellCommandSACL.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/ShellCommandSACL.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -220,7 +220,7 @@ goto Error; }
- pSecurityDescriptor = (PISECURITY_DESCRIPTOR) new unsigned char [dwSecurityDescriptorLength]; + pSecurityDescriptor = (PISECURITY_DESCRIPTOR) new (std::nothrow) unsigned char [dwSecurityDescriptorLength]; if (!pSecurityDescriptor) { _tcsncpy(pszError_msg,_T("\nOut of memory.\n"),ERROR_MSG_BUFFER_SIZE-1); @@ -292,7 +292,7 @@ BOOL blnRet = GetTextualSid(pSID,NULL,&dwSIDStringSize); ASSERT(!blnRet); ASSERT(GetLastError() == ERROR_INSUFFICIENT_BUFFER); - TCHAR *pszSID = new TCHAR[dwSIDStringSize]; + TCHAR *pszSID = new (std::nothrow) TCHAR[dwSIDStringSize];
if (!pszSID) { @@ -315,24 +315,25 @@ rConsole.Write(pszSID); rConsole.Write(_T("\n")); } - delete pszSID; + delete[] pszSID;
TCHAR *pszName, *pszDomainName; DWORD dwNameBufferLength, dwDomainNameBufferLength; dwNameBufferLength = 1024; dwDomainNameBufferLength = 1024;
- pszName = new TCHAR [dwNameBufferLength]; + pszName = new (std::nothrow) TCHAR [dwNameBufferLength]; if (!pszName) { _tcsncpy(pszError_msg,_T("\nOut of memory.\n"),ERROR_MSG_BUFFER_SIZE-1); goto Error; }
- pszDomainName = new TCHAR [dwDomainNameBufferLength]; + pszDomainName = new (std::nothrow) TCHAR [dwDomainNameBufferLength]; if (!pszDomainName) { _tcsncpy(pszError_msg,_T("\nOut of memory.\n"),ERROR_MSG_BUFFER_SIZE-1); + delete[] pszName; goto Error; }
@@ -420,6 +421,9 @@ { rConsole.Write(_T("\t\tKEY_QUERY_VALUE\n")); } + + delete[] pszName; + delete[] pszDomainName; } // for
AbortDumpSACL:
Modified: trunk/rosapps/applications/sysutils/regexpl/ShellCommandSetValue.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/ShellCommandSetValue.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/ShellCommandSetValue.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -395,7 +395,7 @@
SkipCommand: if (pDataBuffer) - delete pDataBuffer; + delete[] pDataBuffer; return 0;
CommandNAonRoot:
Modified: trunk/rosapps/applications/sysutils/regexpl/ShellCommandValue.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/ShellCommandValue.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/ShellCommandValue.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -415,7 +415,7 @@
SkipValueCommand: if (pDataBuffer) - delete pDataBuffer; + delete[] pDataBuffer; return 0; ValueCommandNAonRoot: rConsole.Write(VALUE_CMD COMMAND_NA_ON_ROOT);
Modified: trunk/rosapps/applications/sysutils/regexpl/ShellCommandsLinkedList.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/ShellCommandsLinkedList.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/ShellCommandsLinkedList.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -43,7 +43,7 @@ void CShellCommandsLinkedList::AddCommand(CShellCommand *pCommand) { // Create new node - SNode *pNewNode = new SNode; + SNode *pNewNode = new (std::nothrow) SNode; if (pNewNode == NULL) return;
Modified: trunk/rosapps/applications/sysutils/regexpl/TextHistory.cpp URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/TextHistory.cpp [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/TextHistory.cpp [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -39,7 +39,7 @@
CTextHistory::~CTextHistory() { - if (m_pHistoryBuffer) delete m_pHistoryBuffer; + if (m_pHistoryBuffer) delete[] m_pHistoryBuffer; }
BOOL CTextHistory::Init(DWORD dwMaxHistoryLineSize, DWORD dwMaxHistoryLines) @@ -49,13 +49,13 @@ ASSERT(FALSE); return FALSE; } - if (m_pHistoryBuffer) delete m_pHistoryBuffer; + if (m_pHistoryBuffer) delete[] m_pHistoryBuffer; m_dwFirstHistoryIndex = 0; m_dwLastHistoryIndex = 0; m_dwHisoryFull = 0; m_dwMaxHistoryLines = dwMaxHistoryLines; m_dwMaxHistoryLineSize = dwMaxHistoryLineSize; - m_pHistoryBuffer = new TCHAR [m_dwMaxHistoryLines*dwMaxHistoryLineSize]; + m_pHistoryBuffer = new (std::nothrow) TCHAR [m_dwMaxHistoryLines*dwMaxHistoryLineSize]; if (!m_pHistoryBuffer) return FALSE; return TRUE; }
Modified: trunk/rosapps/applications/sysutils/regexpl/ph.h URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/sysutils/regex... ============================================================================== --- trunk/rosapps/applications/sysutils/regexpl/ph.h [iso-8859-1] (original) +++ trunk/rosapps/applications/sysutils/regexpl/ph.h [iso-8859-1] Thu Oct 6 21:36:10 2011 @@ -27,7 +27,7 @@ #include <winuser.h> #include <winreg.h>
-#include <assert.h> +#include <cassert> #define ASSERT assert #ifdef _DEBUG #define VERIFY ASSERT @@ -36,11 +36,12 @@ #endif
#include <conio.h> -#include <limits.h> +#include <climits> #include <tchar.h> -#include <stdio.h> -#include <stdlib.h> +#include <cstdio> +#include <cstdlib> #include <ctype.h> +#include <new>
// INHERITED_ACE is from windows 2000 #ifndef INHERITED_ACE