Browse Source

* Changed back the query to get the friends of a character to a LEFT JOIN.
* Setting the item script variables to NULL when they are freed. (bugreport:142 ?)
(a double @reloaditemdb might result in a double free)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11328 54d463be-8e91-2dee-dedb-b68131a5f0ec

FlavioJS 17 years ago
parent
commit
fba34ea4ee
3 changed files with 13 additions and 1 deletions
  1. 3 0
      Changelog-Trunk.txt
  2. 1 1
      src/char_sql/char.c
  3. 9 0
      src/map/itemdb.c

+ 3 - 0
Changelog-Trunk.txt

@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2007/09/28
+	* Changed back the query to get the friends of a character to a LEFT JOIN.
+	* Setting the item script variables to NULL when they are freed. (bugreport:142 ?)
+	  (a double @reloaditemdb might result in a double free) [FlavioJS]
 	* Rev. 11325 Corrected Summer Outfit not included as a PC class. (Zephyrus_CR) [L0ne_W0lf]
 	* Rev. 11321 Implemented Summer Outfit care of Zephyrus_CR. [L0ne_W0lf]
 	- Increased MAX_GUILDCASTLE in mmo.h to 29 for future implementation

+ 1 - 1
src/char_sql/char.c

@@ -1016,7 +1016,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
 
 	//read friends
 	//`friends` (`char_id`, `friend_account`, `friend_id`)
-	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `account_id`,`char_id`,`name` FROM `%s` WHERE (`account_id`,`char_id`) IN (SELECT DISTINCT `friend_account`,`friend_id` FROM `%s` WHERE `char_id`=?) LIMIT %d", char_db, friend_db, MAX_FRIENDS)
+	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS)
 	||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
 	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,    &tmp_friend.account_id, 0, NULL, NULL)

+ 9 - 0
src/map/itemdb.c

@@ -769,11 +769,20 @@ static bool itemdb_parse_dbrow(char** str, char* source, int line)
 	id->sex = itemdb_gendercheck(id); //Apply gender filtering.
 
 	if (id->script)
+	{
 		script_free_code(id->script);
+		id->script = NULL;
+	}
 	if (id->equip_script)
+	{
 		script_free_code(id->equip_script);
+		id->equip_script = NULL;
+	}
 	if (id->unequip_script)
+	{
 		script_free_code(id->unequip_script);
+		id->unequip_script = NULL;
+	}
 
 	if (*str[19])
 		id->script = parse_script(str[19], source, line, 0);