From 2175dbec8fd4c0e691b2d3ad83e2dd78e834b8a8 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 5 Dec 2013 19:33:43 +0100 Subject: Follow-up to 6f55c00e72ca6db130a84fe92218f73a777428f4 - Fixed a memory leak (bugreport:7885), thanks to rosfus http://hercules.ws/board/tracker/issue-7885-memory-leaks-found-at-20131205-20h31m31s-rev-13617/ Signed-off-by: Haru --- src/char/int_quest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/char/int_quest.c') diff --git a/src/char/int_quest.c b/src/char/int_quest.c index fb90e8206..ce63a5581 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -38,7 +38,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) { stmt = SQL->StmtMalloc(sql_handle); if (stmt == NULL) { SqlStmt_ShowDebug(stmt); - return 0; + return NULL; } memset(&tmp_quest, 0, sizeof(struct quest)); @@ -70,7 +70,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) { memcpy(&questlog[i++], &tmp_quest, sizeof(tmp_quest)); } if (i < *count) { - // Should never. Compact array + // Should never happen. Compact array *count = i; questlog = aRealloc(questlog, sizeof(struct quest)*i); } @@ -215,6 +215,9 @@ int mapif_parse_quest_load(int fd) { WFIFOSET(fd,num_quests*sizeof(struct quest)+8); + if (tmp_questlog) + aFree(tmp_questlog); + return 0; } -- cgit v1.2.3-60-g2f50