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");