Fix silent error on large ArrayList startsize (#1705)
If there isn't enough memory to resize the ArrayList to the startsize on construction, throw an error instead of ignoring the OOM. Fixes #1551
This commit is contained in:
parent
1ce828b6c8
commit
f7c54e9027
@ -75,7 +75,11 @@ static cell_t CreateArray(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
if (params[2])
|
if (params[2])
|
||||||
{
|
{
|
||||||
array->resize(params[2]);
|
if (!array->resize(params[2]))
|
||||||
|
{
|
||||||
|
delete array;
|
||||||
|
return pContext->ThrowNativeError("Failed to resize array to startsize \"%u\".", params[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
Handle_t hndl = handlesys->CreateHandle(htCellArray, array, pContext->GetIdentity(), g_pCoreIdent, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user