summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authortoms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-29 15:30:41 +0000
committertoms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-29 15:30:41 +0000
commit8262f682cc36a79ce1f21b95243dd955d7aa0f68 (patch)
treeeaa8b254c23ee3abee8940fdc2ce94f64889a83e /src/map/script.c
parentdc28a60fa9820fb455408c5c1f80b514ba241cbc (diff)
downloadhercules-8262f682cc36a79ce1f21b95243dd955d7aa0f68.tar.gz
hercules-8262f682cc36a79ce1f21b95243dd955d7aa0f68.tar.bz2
hercules-8262f682cc36a79ce1f21b95243dd955d7aa0f68.tar.xz
hercules-8262f682cc36a79ce1f21b95243dd955d7aa0f68.zip
Fixed segmentation fault in script engine when calling something which is not a function
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7971 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 729294f48..42fa4ed60 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2458,7 +2458,20 @@ int run_func(struct script_state *st)
int i,start_sp,end_sp,func;
end_sp=st->stack->sp;
+ for(i=end_sp-1;i>=0 && st->stack->stack_data[i].type!=C_ARG;i--);
+ if(i==0){
+ if(battle_config.error_log)
+ ShowError("function not found\n");
+// st->stack->sp=0;
+ st->state=END;
+ report_src(st);
+ return 1;
+ }
+ start_sp=i-1;
+ st->start=i-1;
+ st->end=end_sp;
func=st->stack->stack_data[st->start].u.num;
+
#ifdef DEBUG_RUN
if(battle_config.etc_log) {
ShowDebug("run_func : %s? (%d(%d)) sp=%d (%d...%d)\n",str_buf+str_data[func].str, func, str_data[func].type, st->stack->sp, st->start, st->end);
@@ -2490,21 +2503,9 @@ int run_func(struct script_state *st)
printf("\n");
}
#endif
- for(i=end_sp-1;i>=0 && st->stack->stack_data[i].type!=C_ARG;i--);
- if(i==0){
- if(battle_config.error_log)
- ShowError("function not found\n");
-// st->stack->sp=0;
- st->state=END;
- report_src(st);
- return 1;
- }
- start_sp=i-1;
- st->start=i-1;
- st->end=end_sp;
if(str_data[func].type!=C_FUNC ){
- ShowMessage ("run_func: '"CL_WHITE"%s"CL_RESET"' (type %d) is not function and command!\n");
+ ShowMessage ("run_func: '"CL_WHITE"%s"CL_RESET"' (type %d) is not function and command!\n", str_buf+str_data[func].str, str_data[func].type);
// st->stack->sp=0;
st->state=END;
report_src(st);