瀏覽代碼

Follow-up to r17351 - Fixed memory leaks. Thanks Lighta and Lemongrass for helping!

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17388 54d463be-8e91-2dee-dedb-b68131a5f0ec
akinari1087 12 年之前
父節點
當前提交
c6aa4f8fe3
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      src/char/int_storage.c

+ 8 - 3
src/char/int_storage.c

@@ -296,9 +296,13 @@ int mapif_parse_itembound_retrieve(int fd)
 			i++;
 		}
 	}
+	Sql_FreeResult(sql_handle);
 	
-	if(!i) //No items found - No need to continue
+	if(!i) { //No items found - No need to continue
+		StringBuf_Destroy(&buf);
+		SqlStmt_Free(stmt);
 		return 0;
+	}
 
 	//First we delete the character's items
 	StringBuf_Clear(&buf);
@@ -311,7 +315,6 @@ int mapif_parse_itembound_retrieve(int fd)
 		StringBuf_Printf(&buf, " `id`=%d",items[j].id);
 	}
 
-	stmt = SqlStmt_Malloc(sql_handle);
 	if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
 	||  SQL_ERROR == SqlStmt_Execute(stmt) )
 	{
@@ -342,7 +345,6 @@ int mapif_parse_itembound_retrieve(int fd)
 		StringBuf_AppendStr(&buf, ")");
 	}
 
-	stmt = SqlStmt_Malloc(sql_handle);
 	if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
 	||  SQL_ERROR == SqlStmt_Execute(stmt) )
 	{
@@ -352,6 +354,9 @@ int mapif_parse_itembound_retrieve(int fd)
 		return 1;
 	}
 
+	StringBuf_Destroy(&buf);
+	SqlStmt_Free(stmt);
+
 	//Finally reload storage and tell map we're done
 	mapif_load_guild_storage(fd,aid,guild_id,0);
 	mapif_itembound_ack(fd,aid,guild_id);