Sfoglia il codice sorgente

- Fixed jstrescapecpy crashing when you pass a null string to parse.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5753 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 anni fa
parent
commit
352f81eb40
3 ha cambiato i file con 8 aggiunte e 1 eliminazioni
  1. 2 0
      Changelog-Trunk.txt
  2. 5 0
      src/common/strlib.c
  3. 1 1
      src/map/log.c

+ 2 - 0
Changelog-Trunk.txt

@@ -5,6 +5,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.  EV
 GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
 
 
+2006/03/26
+	* Fixed jstrescapecpy crashing when you pass a null string to parse. [Skotlex]
 2006/03/25
 	* Fixed the map-server freeze/crash on Warp Portal. [Skotlex]
 	* Fixed Grandcross/Granddarkness showing no skill animation. [Skotlex]

+ 5 - 0
src/common/strlib.c

@@ -48,6 +48,11 @@ char* jstrescapecpy (char* pt,char* spt) {
 	//a escape character is found, the target's final length increases! [Skotlex]
 	int i =0, j=0;
 
+	if (!spt) {	//Return an empty string [Skotlex]
+		pt[0] = '\0';
+		return &pt[0];
+	}
+	
 	while (spt[i] != '\0') {
 		switch (spt[i]) {
 			case '\'':

+ 1 - 1
src/map/log.c

@@ -718,7 +718,7 @@ int log_chat(char *type, int type_id, int src_charid, int src_accid, char *map,
 #ifndef TXT_ONLY
 	if(log_config.sql_logs > 0){
 		sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%s')", 
-		 	log_config.log_chat_db, type, type_id, src_charid, src_accid, map, x, y, jstrescapecpy(t_charname, (char *)dst_charname), jstrescapecpy(t_msg, (char *)message));
+		 	log_config.log_chat_db, type, type_id, src_charid, src_accid, map, x, y, jstrescapecpy(t_charname, dst_charname), jstrescapecpy(t_msg, message));
 	
 		if(mysql_query(&logmysql_handle, tmp_sql)){
 			ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));