summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-11-29 00:51:32 +0100
committerHaru <haru@dotalux.com>2013-11-29 00:51:32 +0100
commit0cf52e88ea2779d00c64e36b33e606d658682136 (patch)
treede2fa623d10dc9d647e21af764f820a0537060ef
parent3fae6a6a8f25406aab8cd568e40141c57f2110ce (diff)
downloadhercules-0cf52e88ea2779d00c64e36b33e606d658682136.tar.gz
hercules-0cf52e88ea2779d00c64e36b33e606d658682136.tar.bz2
hercules-0cf52e88ea2779d00c64e36b33e606d658682136.tar.xz
hercules-0cf52e88ea2779d00c64e36b33e606d658682136.zip
Corrected an uninitialized variable when adding an item
- The .favorite field of newly added inventory items wasn't correctly initialized to zero, potentially causing data loss (fixes bugreport:7854, thanks to Vincent, GrumpyPanda). Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r--src/char/char.c1
-rw-r--r--src/map/mob.c2
-rw-r--r--src/map/pc.c4
3 files changed, 5 insertions, 2 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 63b47cfcf..e58fc9eef 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1278,6 +1278,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", cart_db, MAX_CART);
+ memset(&tmp_item, 0, sizeof(tmp_item));
if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
|| SQL_ERROR == SQL->StmtExecute(stmt)
diff --git a/src/map/mob.c b/src/map/mob.c
index 777518d87..1e197756e 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2448,7 +2448,6 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai) {
int log_mvp[2] = {0};
unsigned int mexp;
- struct item item;
double exp;
//mapflag: noexp check [Lorky]
@@ -2471,6 +2470,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
/* pose them randomly in the list -- so on 100% drop servers it wont always drop the same item */
int mdrop_id[MAX_MVP_DROP];
int mdrop_p[MAX_MVP_DROP];
+ struct item item;
memset(&mdrop_id,0,MAX_MVP_DROP*sizeof(int));
diff --git a/src/map/pc.c b/src/map/pc.c
index b5fa9268e..6120ba033 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3997,9 +3997,11 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
return 4;
memcpy(&sd->status.inventory[i], item_data, sizeof(sd->status.inventory[0]));
- // clear equips field first, just in case
+ // clear equip and favorite fields first, just in case
if( item_data->equip )
sd->status.inventory[i].equip = 0;
+ if( item_data->favorite )
+ sd->status.inventory[i].favorite = 0;
sd->status.inventory[i].amount = amount;
sd->inventory_data[i] = data;