From 7afdbbbad8d74f6a4a85417c99f114099a4930b8 Mon Sep 17 00:00:00 2001 From: Dastgir Date: Sat, 25 Jan 2020 17:15:36 +0530 Subject: Added a check in getunits to not proceed if mapname is invalid. --- src/map/script.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/map/script.c b/src/map/script.c index 26bd678fe..039db8ceb 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11775,6 +11775,13 @@ static BUILDIN(getunits) const char *mapname = script_getstr(st, 5); int16 m = map->mapname2mapid(mapname); + if (m == -1) { + ShowError("script:getunits: Invalid map(%s) provided.\n", mapname); + script->reportdata(data); + st->state = END; + return false; + } + if (script_hasdata(st, 9)) { int16 x1 = script_getnum(st, 6); int16 y1 = script_getnum(st, 7); -- cgit v1.2.3-70-g09d2 From f2f6fdec4be88cc1fcb82d7882f3a2fcf0cad7bf Mon Sep 17 00:00:00 2001 From: Dastgir Date: Sat, 25 Jan 2020 17:18:37 +0530 Subject: map_forcountinmap will return 0 if invalid mapindex is provided --- src/map/map.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/map/map.c b/src/map/map.c index afdc2ed41..8639a2a8b 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -638,9 +638,12 @@ static int map_foreachinmap(int (*func)(struct block_list*, va_list), int16 m, i static int map_forcountinmap(int (*func)(struct block_list*, va_list), int16 m, int count, int type, ...) { - int returnCount; + int returnCount = 0; va_list ap; + if (m < 0) + return returnCount; + va_start(ap, type); returnCount = map->vforcountinarea(func, m, 0, 0, map->list[m].xs, map->list[m].ys, count, type, ap); va_end(ap); -- cgit v1.2.3-70-g09d2