summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2020-02-09 23:07:31 +0100
committerGitHub <noreply@github.com>2020-02-09 23:07:31 +0100
commit66b624165ba2e7c868b38081230a61691be447df (patch)
tree77b4c11f6500772c2e8b7106d3d1533d0fe07f42 /src
parentc4ab59ff86fc12d1e7643bbe55a2149c8dc0e56a (diff)
parentf2f6fdec4be88cc1fcb82d7882f3a2fcf0cad7bf (diff)
downloadhercules-66b624165ba2e7c868b38081230a61691be447df.tar.gz
hercules-66b624165ba2e7c868b38081230a61691be447df.tar.bz2
hercules-66b624165ba2e7c868b38081230a61691be447df.tar.xz
hercules-66b624165ba2e7c868b38081230a61691be447df.zip
Merge pull request #2619 from dastgirp/getunits/fix
Crash fixes
Diffstat (limited to 'src')
-rw-r--r--src/map/map.c5
-rw-r--r--src/map/script.c7
2 files changed, 11 insertions, 1 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 8b52fc761..33f3fe716 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);
diff --git a/src/map/script.c b/src/map/script.c
index b89176dba..875f193eb 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);