From 7e76bbb730679d4fe310198891499edeec241c31 Mon Sep 17 00:00:00 2001 From: Kpy! Date: Wed, 22 Apr 2015 17:36:17 +0200 Subject: Fix a crash condition when incorrectly using return outside the scope of a function or subroutine. --- src/map/script.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/map/script.c b/src/map/script.c index b355dfa9e..335f45509 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5682,6 +5682,13 @@ BUILDIN(getarg) /// return; /// return ; BUILDIN(return) { + st->state = RETFUNC; + + if( st->stack->defsp < 1 || st->stack->stack_data[st->stack->defsp-1].type != C_RETINFO ) { + // Incorrect usage of return outside the scope of a function or subroutine. + return true; // No need for further processing, running script is about to be aborted. + } + if( script_hasdata(st,2) ) {// return value struct script_data* data; @@ -5712,7 +5719,7 @@ BUILDIN(return) { {// no return value script_pushnil(st); } - st->state = RETFUNC; + return true; } -- cgit v1.2.3-60-g2f50