Missing returns for inarray and countinarray (#3295)
Added some return cases if empty arrays are given to these two commands. Thanks to @sader1992
This commit is contained in:
parent
255baff290
commit
500cfdc41f
@ -6415,6 +6415,12 @@ BUILDIN_FUNC(inarray)
|
|||||||
|
|
||||||
array_size = script_array_highest_key(st, sd, name, ref) - 1;
|
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)
|
if (array_size > SCRIPT_MAX_ARRAYSIZE)
|
||||||
{
|
{
|
||||||
ShowError("buildin_inarray: The array is too large.\n");
|
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_size1 = script_array_highest_key(st, sd, name1, ref1) - 1;
|
||||||
array_size2 = script_array_highest_key(st, sd, name2, ref2) - 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)
|
if (array_size1 > SCRIPT_MAX_ARRAYSIZE || array_size2 > SCRIPT_MAX_ARRAYSIZE)
|
||||||
{
|
{
|
||||||
ShowError("buildin_countinarray: The array is too large.\n");
|
ShowError("buildin_countinarray: The array is too large.\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user