[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

svn path=/trunk/; revision=54034
This commit is contained in:
Pierre Schweitzer 2011-10-06 21:36:10 +00:00
parent 7e02fbd0dd
commit c91f9ef382
16 changed files with 100 additions and 82 deletions

View file

@ -49,9 +49,9 @@ public:
size_t s = _tcslen(pszText);
if (m_pszText)
delete 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 "
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 @@ public:
~CCompletionMatch()
{
if (m_pszText)
delete m_pszText;
delete[] m_pszText;
}
private:
@ -129,20 +129,20 @@ CCompletionList::~CCompletionList()
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 @@ BOOL CCompletionList::IsNewCompletion(const TCHAR *pszContext, const TCHAR *pszB
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 @@ BOOL CCompletionList::Add(const TCHAR *pszText, BOOL blnIsKey)
{
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 @@ BOOL FillCompletion(const TCHAR *pszKey)
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 @@ BOOL FillCompletion(const TCHAR *pszKey)
goto Abort;
}
pszValueName = new TCHAR[nKeyNameSize+dwMaxValueNameSize+1];
pszValueName = new (std::nothrow) TCHAR[nKeyNameSize+dwMaxValueNameSize+1];
if (!pszValueName)
goto Abort;
@ -415,15 +425,15 @@ BOOL FillCompletion(const TCHAR *pszKey)
}
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;
}

View file

@ -71,11 +71,11 @@ CConsole::CConsole()
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 @@ TCHAR * CConsole::Init(DWORD dwBufferSize, DWORD dwMaxHistoryLines)
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 @@ Abort:
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;

View file

@ -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 @@ HRESULT CPrompt::SetPrompt(LPCTSTR pszPrompt)
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 @@ HRESULT CPrompt::SetPrompt(LPCTSTR pszPrompt)
CPrompt::~CPrompt()
{
if (m_pszPrompt)
delete m_pszPrompt;
delete[] m_pszPrompt;
}
void CPrompt::ShowPrompt(CConsole &rConsole)

View file

@ -138,7 +138,7 @@ int main ()
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 @@ int main ()
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"));

View file

@ -70,7 +70,7 @@ HRESULT CRegistryKey::InitRoot(const TCHAR *pszMachineName)
{ // 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 @@ HRESULT CRegistryKey::Init(HKEY hKey, const TCHAR *pszPath, const TCHAR *pszKeyN
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 @@ LONG CRegistryKey::OpenSubkey(REGSAM samDesired, const TCHAR *pszSubkeyName, CRe
{
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 @@ LONG CRegistryKey::OpenSubkey(REGSAM samDesired, const TCHAR *pszSubkeyName, CRe
_tcscpy(pszSubkeyFullName,pszKeyName);
_tcscat(pszSubkeyFullName,pszSubkeyName);
HRESULT hr = rKey.Init(hKey,GetKeyName(),pszSubkeyName,samDesired);
delete pszSubkeyName;
delete[] pszSubkeyName;
if (FAILED(hr))
{
nError = RegCloseKey(hKey);

View file

@ -64,7 +64,7 @@ CRegistryTree::CRegistryTree(const CRegistryTree& Tree)
CRegistryTree::~CRegistryTree()
{
if (m_pszMachineName)
delete m_pszMachineName;
delete[] m_pszMachineName;
CNode *pNode;
while(m_pCurrentKey->m_pUp)
@ -98,7 +98,7 @@ BOOL CRegistryTree::ChangeCurrentKey(const TCHAR *pszRelativePath)
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 @@ BOOL CRegistryTree::ChangeCurrentKey(const TCHAR *pszRelativePath)
return TRUE;
Abort:
delete pszBuffer;
delete[] pszBuffer;
return FALSE;
}
@ -179,7 +179,7 @@ BOOL CRegistryTree::SetMachineName(LPCTSTR pszMachineName)
{
// 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 @@ BOOL CRegistryTree::SetMachineName(LPCTSTR pszMachineName)
ASSERT(*pszMachineName); // No machine name.
TCHAR *pszNewMachineName = new TCHAR[_tcslen(pszMachineName)+3]; // two leading backslashes + terminating null
TCHAR *pszNewMachineName = new (std::nothrow) TCHAR[_tcslen(pszMachineName)+3]; // two leading backslashes + terminating null
if (!pszMachineName)
if (!pszNewMachineName)
{
SetError(ERROR_OUTOFMEMORY);
return FALSE;
@ -202,7 +202,7 @@ BOOL CRegistryTree::SetMachineName(LPCTSTR pszMachineName)
// Delete previous machine name buffer if allocated.
if (m_pszMachineName)
delete m_pszMachineName;
delete[] m_pszMachineName;
m_pszMachineName = pszNewMachineName;
@ -283,7 +283,7 @@ BOOL CRegistryTree::DeleteSubkeys(CRegistryKey& rKey, const TCHAR *pszKeyPattern
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 @@ void CRegistryTree::SetErrorCommandNAOnRoot(const TCHAR *pszCommand)
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 @@ BOOL CRegistryTree::InternalChangeCurrentKey(const TCHAR *pszSubkeyName, REGSAM
if (_tcscmp(pszSubkeyName,_T(".")) == 0)
{
delete pszSubkeyNameBuffer;
delete[] pszSubkeyNameBuffer;
return TRUE;
}
@ -421,7 +421,7 @@ BOOL CRegistryTree::InternalChangeCurrentKey(const TCHAR *pszSubkeyName, REGSAM
// 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 @@ BOOL CRegistryTree::InternalChangeCurrentKey(const TCHAR *pszSubkeyName, REGSAM
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 @@ BOOL CRegistryTree::InternalChangeCurrentKey(const TCHAR *pszSubkeyName, REGSAM
{
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 @@ BOOL CRegistryTree::InternalGetSubkey(const TCHAR *pszSubkeyName, REGSAM Desired
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 @@ BOOL CRegistryTree::InternalGetSubkey(const TCHAR *pszSubkeyName, REGSAM Desired
if (nError != ERROR_SUCCESS)
{
delete pszSubkeyNameCaseUpdated;
delete[] pszSubkeyNameCaseUpdated;
pszSubkeyNameCaseUpdated = NULL;
}
@ -513,7 +513,7 @@ SkipCaseUpdate:
goto Abort;
}
delete pszSubkeyNameCaseUpdated;
delete[] pszSubkeyNameCaseUpdated;
}
else
{
@ -535,7 +535,7 @@ SkipCaseUpdate:
return TRUE;
Abort:
if (pszSubkeyNameCaseUpdated)
delete pszSubkeyNameCaseUpdated;
delete[] pszSubkeyNameCaseUpdated;
if (hNewKey)
{
@ -611,7 +611,7 @@ BOOL CRegistryTree::GetKey(const TCHAR *pszRelativePath, REGSAM DesiredAccess, C
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 @@ BOOL CRegistryTree::GetKey(const TCHAR *pszRelativePath, REGSAM DesiredAccess, C
// change to parent key
if (!Tree.InternalChangeCurrentKey(_T(".."),READ_CONTROL))
{
delete[] pszShortKeyName;
ASSERT(FALSE);
SetInternalError();
return FALSE;
@ -632,10 +633,12 @@ BOOL CRegistryTree::GetKey(const TCHAR *pszRelativePath, REGSAM DesiredAccess, C
// change back to target key
if (!Tree.InternalGetSubkey(pszShortKeyName,DesiredAccess,rKey))
{
delete[] pszShortKeyName;
SetError(Tree.GetLastErrorDescription());
return FALSE;
}
delete[] pszShortKeyName;
return TRUE;
}

View file

@ -47,7 +47,7 @@ HRESULT CSettings::Clean()
{
if (m_pszPrompt)
{
delete m_pszPrompt;
delete[] m_pszPrompt;
m_pszPrompt = NULL;
}
@ -75,7 +75,7 @@ HRESULT CSettings::Load(LPCTSTR pszLoadKey)
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;

View file

@ -226,7 +226,7 @@ CheckDACLArgument:
rConsole.Write(pchSID);
rConsole.Write(_T("\n"));
}
delete pchSID;
delete[] pchSID;
DWORD dwNameBufferLength, dwDomainNameBufferLength;
dwNameBufferLength = 1024;
dwDomainNameBufferLength = 1024;

View file

@ -147,7 +147,7 @@ CheckValueArgument:
return 0;
}
TCHAR *pszValueName = new TCHAR[dwMaxValueNameLength];
TCHAR *pszValueName = new (std::nothrow) TCHAR[dwMaxValueNameLength];
if (!pszValueName)
{
rConsole.Write("Out of memory.");

View file

@ -200,7 +200,7 @@ CheckDirArgument:
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 @@ CheckDirArgument:
}
}
delete pszSubkeyNameBuffer;
delete[] pszSubkeyNameBuffer;
if (nError != ERROR_NO_MORE_ITEMS)
throw nError;
@ -226,7 +226,7 @@ CheckDirArgument:
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 @@ CheckDirArgument:
}
}
delete pchValueNameBuffer;
delete[] pchValueNameBuffer;
if (nError != ERROR_NO_MORE_ITEMS)
throw nError;

View file

@ -220,7 +220,7 @@ CheckSACLArgument:
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 @@ CheckSACLArgument:
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 @@ CheckSACLArgument:
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 @@ CheckSACLArgument:
{
rConsole.Write(_T("\t\tKEY_QUERY_VALUE\n"));
}
delete[] pszName;
delete[] pszDomainName;
} // for
AbortDumpSACL:

View file

@ -395,7 +395,7 @@ CheckValueArgument:
SkipCommand:
if (pDataBuffer)
delete pDataBuffer;
delete[] pDataBuffer;
return 0;
CommandNAonRoot:

View file

@ -415,7 +415,7 @@ CheckValueArgument:
SkipValueCommand:
if (pDataBuffer)
delete pDataBuffer;
delete[] pDataBuffer;
return 0;
ValueCommandNAonRoot:
rConsole.Write(VALUE_CMD COMMAND_NA_ON_ROOT);

View file

@ -43,7 +43,7 @@ CShellCommandsLinkedList::~CShellCommandsLinkedList()
void CShellCommandsLinkedList::AddCommand(CShellCommand *pCommand)
{
// Create new node
SNode *pNewNode = new SNode;
SNode *pNewNode = new (std::nothrow) SNode;
if (pNewNode == NULL)
return;

View file

@ -39,7 +39,7 @@ CTextHistory::CTextHistory()
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 @@ BOOL CTextHistory::Init(DWORD dwMaxHistoryLineSize, DWORD dwMaxHistoryLines)
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;
}

View file

@ -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