summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-02-17 13:36:49 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-02-17 13:36:49 +0000
commit25fac517af46dd681e1fe9b9d5bd1406ff9d1108 (patch)
tree19452a6a3c30828573e07b3da39c91e66a885bfe
parentde9a845f5bf8493cb4e03da261340055972508b3 (diff)
downloadhercules-25fac517af46dd681e1fe9b9d5bd1406ff9d1108.tar.gz
hercules-25fac517af46dd681e1fe9b9d5bd1406ff9d1108.tar.bz2
hercules-25fac517af46dd681e1fe9b9d5bd1406ff9d1108.tar.xz
hercules-25fac517af46dd681e1fe9b9d5bd1406ff9d1108.zip
- Fixed the memory leak on opt_2str as pointed out by End of Exam
- Fixed a few char SQL memory leaks as pointed out by End of Exam git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5307 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt4
-rw-r--r--src/char_sql/char.c11
-rw-r--r--src/map/script.c6
3 files changed, 16 insertions, 5 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index af7edf6f7..08774b908 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,6 +3,10 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EVERYTHING ELSE
GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
+
+2006/02/17
+ * Fixed the memory leak on opt_2str as pointed out by End of Exam [Skotlex]
+ * Fixed a few char SQL memory leaks as pointed out by End of Exam [Skotlex]
2006/02/16
* Fixed a crash in AL_TELEPORT. [Skotlex]
* Now you can't close-confine and already confined mob. [Skotlex]
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 7d3ddf008..c3e599419 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -1927,7 +1927,7 @@ int parse_tologin(int fd) {
{
int acc, sex;
unsigned char buf[16];
-
+ MYSQL_RES* sql_res2; //Needed because it is used inside inter_guild_CharOffline; [Skotlex]
acc = RFIFOL(fd,2);
sex = RFIFOB(fd,6);
RFIFOSKIP(fd, 7);
@@ -1937,9 +1937,9 @@ int parse_tologin(int fd) {
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
- sql_res = mysql_store_result(&mysql_handle);
+ sql_res2 = mysql_store_result(&mysql_handle);
- while(sql_res && (sql_row = mysql_fetch_row(sql_res))) {
+ while(sql_res2 && (sql_row = mysql_fetch_row(sql_res2))) {
int char_id, guild_id, jobclass, skill_point, class_;
char_id = atoi(sql_row[0]);
jobclass = atoi(sql_row[1]);
@@ -1968,6 +1968,7 @@ int parse_tologin(int fd) {
while(( sql_row = mysql_fetch_row(sql_res))) {
skill_point += atoi(sql_row[0]);
}
+ mysql_free_result(sql_res);
}
sprintf(tmp_sql, "DELETE FROM `%s` WHERE `char_id` = '%d' AND `id` >= '315' AND `id` <= '330'",skill_db, char_id);
if (mysql_query(&mysql_handle, tmp_sql)) {
@@ -1990,6 +1991,8 @@ int parse_tologin(int fd) {
if (guild_id) //If there is a guild, update the guild_member data [Skotlex]
inter_guild_sex_changed(guild_id, acc, char_id, sex);
}
+ if (sql_res2)
+ mysql_free_result(sql_res2);
}
// disconnect player if online on char-server
for(i = 0; i < fd_max; i++) {
@@ -2348,6 +2351,7 @@ int parse_frommap(int fd) {
memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &data, sizeof(struct status_change_data));
count++;
}
+ mysql_free_result(sql_res);
if (count > 0)
{
WFIFOW(fd, 2) = 14 + count*sizeof(struct status_change_data);
@@ -2681,6 +2685,7 @@ int parse_frommap(int fd) {
if (acc != -1) {
WFIFOSET(fd, 34);
}
+ mysql_free_result(sql_res);
}
}
RFIFOSKIP(fd, 44);
diff --git a/src/map/script.c b/src/map/script.c
index 19d52b026..6560d3281 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9854,8 +9854,9 @@ void op_2str(struct script_state *st,int op,int sp1,int sp2)
break;
}
- push_val(st->stack,C_INT,a);
-
+ // Because push_val() overwrite stack_data[sp1], C_STR on stack_data[sp1] won't be freed.
+ // So, call push_val() after freeing strings. [jA1783]
+ // push_val(st->stack,C_INT,a);
if(st->stack->stack_data[sp1].type==C_STR)
{
aFree(s1);
@@ -9866,6 +9867,7 @@ void op_2str(struct script_state *st,int op,int sp1,int sp2)
aFree(s2);
st->stack->stack_data[sp2].type=C_INT;
}
+ push_val(st->stack,C_INT,a);
}
/*==========================================
* 񍀉Zq(l)