mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
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
|
// 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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user