summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-04 14:31:37 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-04 19:25:06 +0300
commit3011243a6892d8877443e46b05085a459d722e12 (patch)
tree91ca576a45c9cd59071be7308999fa9f36f364e1 /src
parent4bcf57902a9a7e915a8c25f220f595fe0b59ae91 (diff)
downloadhercules-s20160706.tar.gz
hercules-s20160706.tar.bz2
hercules-s20160706.tar.xz
hercules-s20160706.zip
Add one check for possible script issue.s20160706release2016-07-04
Diffstat (limited to 'src')
-rw-r--r--src/map/script.c18
-rw-r--r--src/map/script.h2
2 files changed, 16 insertions, 4 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) {
diff --git a/src/map/script.h b/src/map/script.h
index 61c6a4583..4df8941b7 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -758,7 +758,7 @@ struct script_interface {
void (*op_2num) (struct script_state *st, int op, int i1, int i2);
void (*op_2) (struct script_state *st, int op);
void (*op_1) (struct script_state *st, int op);
- void (*check_buildin_argtype) (struct script_state *st, int func);
+ bool (*check_buildin_argtype) (struct script_state *st, int func);
void (*detach_state) (struct script_state *st, bool dequeue_event);
int (*db_free_code_sub) (union DBKey key, struct DBData *data, va_list ap);
void (*add_autobonus) (const char *autobonus);