From 88a0a458a6231f983297f0b92a89383c4674727d Mon Sep 17 00:00:00 2001 From: peace-maker Date: Mon, 31 Jan 2022 22:07:32 +0100 Subject: [PATCH] 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 --- core/logic/smn_adt_array.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/logic/smn_adt_array.cpp b/core/logic/smn_adt_array.cpp index b8694bce..fe91b317 100644 --- a/core/logic/smn_adt_array.cpp +++ b/core/logic/smn_adt_array.cpp @@ -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);