Skip to content

Commit

Permalink
Fix silent error on large ArrayList startsize (#1705)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
peace-maker committed Jan 31, 2022
1 parent 1ce828b commit f7c54e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/logic/smn_adt_array.cpp
Expand Up @@ -75,7 +75,11 @@ static cell_t CreateArray(IPluginContext *pContext, const cell_t *params)

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);
Expand Down

0 comments on commit f7c54e9

Please sign in to comment.