From 500cfdc41fd64a9e5d84c6479c072cc56003854e Mon Sep 17 00:00:00 2001 From: Sader Fawall Date: Sat, 7 Jul 2018 13:46:14 +0200 Subject: [PATCH] Missing returns for inarray and countinarray (#3295) Added some return cases if empty arrays are given to these two commands. Thanks to @sader1992 --- src/map/script.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/map/script.cpp b/src/map/script.cpp index 59df9cd916..60ad417cde 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -6415,6 +6415,12 @@ BUILDIN_FUNC(inarray) array_size = script_array_highest_key(st, sd, name, ref) - 1; + if (array_size < 0) + { + script_pushint(st, -1); + return SCRIPT_CMD_SUCCESS; + } + if (array_size > SCRIPT_MAX_ARRAYSIZE) { ShowError("buildin_inarray: The array is too large.\n"); @@ -6497,6 +6503,12 @@ BUILDIN_FUNC(countinarray) array_size1 = script_array_highest_key(st, sd, name1, ref1) - 1; array_size2 = script_array_highest_key(st, sd, name2, ref2) - 1; + if (array_size1 < 0 || array_size2 < 0) + { + script_pushint(st, 0); + return SCRIPT_CMD_SUCCESS; + } + if (array_size1 > SCRIPT_MAX_ARRAYSIZE || array_size2 > SCRIPT_MAX_ARRAYSIZE) { ShowError("buildin_countinarray: The array is too large.\n");