- 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://svn.code.sf.net/p/rathena/svn/trunk@5307 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2006-02-17 13:36:49 +00:00
parent 280ad53713
commit eafb17b8fe
3 changed files with 16 additions and 5 deletions

View File

@ -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]

View File

@ -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);

View File

@ -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);
}
/*==========================================
* ñ<EFBFBD>ŽZŽq(<EFBFBD>l)