From 0fb0df3a0fa3ac24f9f068d0c1ac664beec03354 Mon Sep 17 00:00:00 2001 From: skotlex Date: Tue, 5 Sep 2006 19:49:38 +0000 Subject: - Corrected SC_INTRAVISION not starting. - Small cleanups (line terminators, indenting) - Fixed crash when attempting to read a Label as a string on a script (thanks to End of Exam) - Fixed possible crash when changing a chat-room's owner (thanks to End of Exam) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8639 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/script.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index f881a5548..168cfb857 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -559,8 +559,7 @@ unsigned char* parse_simpleexpr(unsigned char *p) int c,l; char *p2; // label , register , function etc - //From what I read, jA figured a better way to handle empty parenthesis '()' - if(skip_word(p)==p/* && !(*p==')' && p[-1]=='(')*/){ + if(skip_word(p)==p){ disp_error_message("unexpected character",p); exit(1); } @@ -1494,7 +1493,6 @@ static void read_constdb(void) type=0; if(sscanf(line,"%[A-Za-z0-9_],%[0-9xXA-Fa-f],%d",name,val,&type)>=2 || sscanf(line,"%[A-Za-z0-9_] %[0-9xXA-Fa-f] %d",name,val,&type)>=2){ - for(i=0;name[i];i++) name[i]=tolower(name[i]); n=add_str((const unsigned char *) name); @@ -1929,12 +1927,13 @@ char* conv_str(struct script_state *st,struct script_data *data) snprintf(buf,ITEM_NAME_LENGTH, "%d",data->u.num); data->type=C_STR; data->u.str=buf; -#if 1 + } else if(data->type==C_POS) { + // Protect form crashes by passing labels to string-expected args [jA2200] + data->type = C_CONSTSTR; + data->u.str = "** SCRIPT ERROR **"; } else if(data->type==C_NAME){ - // テンポラリ。本来無いはず data->type=C_CONSTSTR; data->u.str=str_buf+str_data[data->u.num].str; -#endif } return data->u.str; } @@ -2630,10 +2629,10 @@ void run_script_main(struct script_state *st) if(stack->sp > stack->defsp) { //sp > defsp is valid in cases when you invoke functions and don't use the returned value. [Skotlex] //Since sp is supposed to be defsp in these cases, we could assume the extra stack elements are unneeded. - if (battle_config.etc_log) - { - ShowWarning("Clearing unused stack stack.sp(%d) -> default(%d)\n",stack->sp,stack->defsp); - report_src(st); + if (battle_config.etc_log) + { + ShowWarning("Clearing unused stack stack.sp(%d) -> default(%d)\n",stack->sp,stack->defsp); + report_src(st); } pop_stack(stack, stack->defsp, stack->sp); //Clear out the unused stack-section. } else if(battle_config.error_log) @@ -2791,7 +2790,6 @@ int mapreg_setreg(int num,int val) } } #endif - // else } else { // [zBuffer] #if !defined(TXT_ONLY) && defined(MAPREGSQL) if(name[1] != '@') { // Remove from database because it is unused. @@ -11715,7 +11713,6 @@ int buildin_axtoi(struct script_state *st) return 0; } - // [zBuffer] List of player cont commands ---> int buildin_rid2name(struct script_state *st){ struct block_list *bl = NULL; -- cgit v1.2.3-70-g09d2