From d2e01da287bdede81ed8003ea55482140e265ecc Mon Sep 17 00:00:00 2001 From: Sean Lewis Date: Sat, 6 Dec 2014 17:07:54 -0600 Subject: [PATCH] Wrap 3rd parameter in FindValueInArray to check for existence. --- core/logic/smn_adt_array.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/logic/smn_adt_array.cpp b/core/logic/smn_adt_array.cpp index 7d41c872..d8896add 100644 --- a/core/logic/smn_adt_array.cpp +++ b/core/logic/smn_adt_array.cpp @@ -550,7 +550,13 @@ static cell_t FindValueInArray(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err); } - size_t blocknumber = (size_t) params[3]; + // the blocknumber is not guaranteed to always be passed + size_t blocknumber = 0; + if (params[0] >= 3) + { + blocknumber = (size_t) params[3]; + } + if (blocknumber >= array->blocksize()) { return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());