Added a check for memory allocation failure
This commit is contained in:
parent
3d3775ec00
commit
642eb769b2
|
@ -86,6 +86,10 @@ void EventsMngr::NextParam()
|
|||
{
|
||||
// copy to tmp
|
||||
tmp = new MsgDataEntry[m_ParseVaultSize];
|
||||
if (!tmp)
|
||||
{
|
||||
return; // :TODO: Error report !!
|
||||
}
|
||||
memcpy(tmp, m_ParseVault, m_ParseVaultSize * sizeof(MsgDataEntry));
|
||||
tmpSize = m_ParseVaultSize;
|
||||
delete [] m_ParseVault;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
tmp = new AMXForward;
|
||||
if (!tmp)
|
||||
return; // :TODO: Better error report!!!
|
||||
tmp->pPlugin = &(*iter);
|
||||
tmp->func = func;
|
||||
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 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ int MenuMngr::registerMenuId(const char* n, AMX* a )
|
|||
int id = findMenuId( n, a );
|
||||
if (id) return id;
|
||||
headid = new MenuIdEle( n, a , headid );
|
||||
if (headid)
|
||||
return 0; // :TODO: Better error report
|
||||
return headid->id;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user