diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-04 14:31:37 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-04 18:40:30 +0300 |
commit | d5baa8a68e3bb65681c0168920a461b2675d2dfd (patch) | |
tree | c3b8f2cd62288096868409ac289b2c0043032118 /src/map/script.c | |
parent | d2f666fc10eac20f70729176c088b2c81d233531 (diff) | |
download | hercules-d5baa8a68e3bb65681c0168920a461b2675d2dfd.tar.gz hercules-d5baa8a68e3bb65681c0168920a461b2675d2dfd.tar.bz2 hercules-d5baa8a68e3bb65681c0168920a461b2675d2dfd.tar.xz hercules-d5baa8a68e3bb65681c0168920a461b2675d2dfd.zip |
Add one check for possible script issue.
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/map/script.c b/src/map/script.c index 12f7dd43c..ed38ed1c5 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -4042,10 +4042,17 @@ void op_1(struct script_state* st, int op) /// /// @param st Script state whose stack arguments should be inspected. /// @param func Built-in function for which the arguments are intended. -void script_check_buildin_argtype(struct script_state* st, int func) +bool script_check_buildin_argtype(struct script_state* st, int func) { int idx, invalid = 0; - char* sf = script->buildin[script->str_data[func].val]; + char* sf; + if (script->str_data[func].val < 0 || script->str_data[func].val >= script->buildin_count) { + ShowDebug("Function: %s\n", script->get_str(func)); + ShowError("Script data corruption detected!\n"); + script->reportsrc(st); + return false; + } + sf = script->buildin[script->str_data[func].val]; for (idx = 2; script_hasdata(st, idx); idx++) { struct script_data* data = script_getdata(st, idx); @@ -4116,6 +4123,7 @@ void script_check_buildin_argtype(struct script_state* st, int func) ShowDebug("Function: %s\n", script->get_str(func)); script->reportsrc(st); } + return true; } /// Executes a buildin command. @@ -4153,7 +4161,11 @@ int run_func(struct script_state *st) } if( script->config.warn_func_mismatch_argtypes ) { - script->check_buildin_argtype(st, func); + if (script->check_buildin_argtype(st, func) == false) + { + st->state = END; + return 1; + } } if(script->str_data[func].func) { |