Added a check for memory allocation failure

This commit is contained in:
Pavol Marko 2004-05-28 11:24:59 +00:00
parent 3d3775ec00
commit 642eb769b2
3 changed files with 12 additions and 1 deletions

View File

@ -86,6 +86,10 @@ void EventsMngr::NextParam()
{ {
// copy to tmp // copy to tmp
tmp = new MsgDataEntry[m_ParseVaultSize]; tmp = new MsgDataEntry[m_ParseVaultSize];
if (!tmp)
{
return; // :TODO: Error report !!
}
memcpy(tmp, m_ParseVault, m_ParseVaultSize * sizeof(MsgDataEntry)); memcpy(tmp, m_ParseVault, m_ParseVaultSize * sizeof(MsgDataEntry));
tmpSize = m_ParseVaultSize; tmpSize = m_ParseVaultSize;
delete [] m_ParseVault; delete [] m_ParseVault;

View File

@ -46,6 +46,8 @@ CForward::CForward(const char *name, ForwardExecType et, int numParams, const Fo
if (amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE) if (amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
{ {
tmp = new AMXForward; tmp = new AMXForward;
if (!tmp)
return; // :TODO: Better error report!!!
tmp->pPlugin = &(*iter); tmp->pPlugin = &(*iter);
tmp->func = func; tmp->func = func;
m_Funcs.put(tmp); m_Funcs.put(tmp);
@ -267,7 +269,10 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
int CForwardMngr::registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam * paramTypes) int CForwardMngr::registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam * paramTypes)
{ {
int retVal = m_Forwards.size() << 1; int retVal = m_Forwards.size() << 1;
m_Forwards.push_back(new CForward(funcName, et, numParams, paramTypes)); CForward *tmp = new CForward(funcName, et, numParams, paramTypes);
if (!tmp)
return -1; // should be invalid
m_Forwards.push_back(tmp);
return retVal; return retVal;
} }

View File

@ -62,6 +62,8 @@ int MenuMngr::registerMenuId(const char* n, AMX* a )
int id = findMenuId( n, a ); int id = findMenuId( n, a );
if (id) return id; if (id) return id;
headid = new MenuIdEle( n, a , headid ); headid = new MenuIdEle( n, a , headid );
if (headid)
return 0; // :TODO: Better error report
return headid->id; return headid->id;
} }