summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt3
-rw-r--r--src/char_sql/char.c2
-rw-r--r--src/map/itemdb.c9
3 files changed, 13 insertions, 1 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 8ff064239..889394170 100644
--- a/Changelog-Trunk.txt
+++ b/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
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 64e341c11..178454e73 100644
--- a/src/char_sql/char.c
+++ b/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)
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index f6cdf6b3f..91eaeafce 100644
--- a/src/map/itemdb.c
+++ b/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);