diff options
author | gumi <git@gumi.ca> | 2018-03-08 10:14:17 -0500 |
---|---|---|
committer | gumi <git@gumi.ca> | 2018-03-08 10:14:17 -0500 |
commit | d968b4ad3e8af9655f29f3aa1d473c211a62dcd7 (patch) | |
tree | 04268227c54ff0e135d404d07b414dc5b97e2a3d | |
parent | 535dece441bceeaf013457ea0e3cc048fc78017c (diff) | |
download | tmwa-d968b4ad3e8af9655f29f3aa1d473c211a62dcd7.tar.gz tmwa-d968b4ad3e8af9655f29f3aa1d473c211a62dcd7.tar.bz2 tmwa-d968b4ad3e8af9655f29f3aa1d473c211a62dcd7.tar.xz tmwa-d968b4ad3e8af9655f29f3aa1d473c211a62dcd7.zip |
fix some out-of-memory reads in script builtins
-rw-r--r-- | src/map/script-fun.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 02aefbb..e1866bc 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -286,7 +286,7 @@ void builtin_callsub(ScriptState *st) static void builtin_return(ScriptState *st) { - if (!(st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>())) + if (st->defsp < 1 || !(st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>())) { dumb_ptr<npc_data> nd = map_id_is_npc(st->oid); if(nd) @@ -323,7 +323,7 @@ void builtin_next(ScriptState *st) static void builtin_close(ScriptState *st) { - if (st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>()) + if (st->defsp >= 1 && st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>()) { dumb_ptr<npc_data> nd = map_id_is_npc(st->oid); if(nd) @@ -2312,7 +2312,7 @@ void builtin_getgmlevel(ScriptState *st) static void builtin_end(ScriptState *st) { - if (st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>()) + if (st->defsp >= 1 && st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>()) { dumb_ptr<npc_data> nd = map_id_is_npc(st->oid); if(nd) |