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:
peace-maker
2023-08-30 22:08:45 +02:00
committed by Your Name
parent e4afe31fc0
commit 88a0a458a6
+5 -1
View File
@@ -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);