diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-10-10 21:51:56 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-10-10 21:51:56 +0000 |
commit | a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f (patch) | |
tree | 0072a5eb971520d234780328481300fb9c84b359 /src/map/script.c | |
parent | 69ebeeb417756359eee461ea9db90d96564d8536 (diff) | |
download | hercules-a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f.tar.gz hercules-a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f.tar.bz2 hercules-a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f.tar.xz hercules-a4bb0c3ad6d6ba04cfe3f142da460bcf836e069f.zip |
* Fixed itemdb_read_sqldb blowing up the server with segmentation faults.
* Added an option for parse_script to ignore the checks for the set of brackets around the script.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11398 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/map/script.c b/src/map/script.c index d229b95ef..1fa0f3150 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -1898,6 +1898,9 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o struct script_code *code; static int first=1; + if( src == NULL ) + return NULL;// empty script + memset(&syntax,0,sizeof(syntax)); if(first){ add_buildin_func(); @@ -1948,21 +1951,34 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o parse_syntax_for_flag=0; p=src; p=skip_space(p); - if(*p!='{'){ - disp_error_message("not found '{'",p); + if( options&SCRIPT_IGNORE_EXTERNAL_BRACKETS ) + {// does not require brackets around the script + if( *p == '\0' ) + {// empty script + aFree( script_buf ); + script_pos = 0; + script_size = 0; + script_buf = NULL; + return NULL; + } } - p++; - p = skip_space(p); - if (p && *p == '}') { - // an empty function, just return - aFree( script_buf ); - script_pos = 0; - script_size = 0; - script_buf = NULL; - return NULL; + else + {// requires brackets around the script + if( *p != '{' ) + disp_error_message("not found '{'",p); + p = skip_space(++p); + if( *p == '}' ) + {// empty script + aFree( script_buf ); + script_pos = 0; + script_size = 0; + script_buf = NULL; + return NULL; + } } - while (p && *p && (*p!='}' || syntax.curly_count != 0)) { + while (*p && (*p != '}' || syntax.curly_count != 0) ) + { p=skip_space(p); // labelだけ特殊処理 tmpp=skip_space(skip_word(p)); |