Skip to content

Commit

Permalink
Merge pull request #3278 from skyleo/emblem-memory-leaks
Browse files Browse the repository at this point in the history
Fix memory leaks of emblem_data
  • Loading branch information
MishimaHaruna committed Feb 5, 2024
2 parents eb142b5 + ad7b9e8 commit 1c386f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/char/int_guild.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static int inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data)
// Nothing to save, guild is ready for removal.
if (chr->show_save_log)
ShowInfo("Guild Unloaded (%d - %s)\n", g->guild_id, g->name);
aFree(g->emblem_data);
db_remove(inter_guild->guild_db, key);
}
}
Expand Down Expand Up @@ -1207,6 +1208,7 @@ static bool inter_guild_disband(int guild_id)
inter->log("guild %s (id=%d) broken\n", g->name, guild_id);

//Remove the guild from memory. [Skotlex]
aFree(g->emblem_data);
idb_remove(inter_guild->guild_db, guild_id);

return true;
Expand Down
2 changes: 2 additions & 0 deletions src/map/guild.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ static int guild_recv_info(const struct guild *sg, struct fifo_chunk_buf *emblem
g->emblem_data = NULL;
g->emblem_len = 0;
} else {
if (!guild_new)
aFree(before.emblem_data);
g->emblem_data = aMalloc(emblem_buf->data_size);
memcpy(g->emblem_data, emblem_buf->data, emblem_buf->data_size);
}
Expand Down

0 comments on commit 1c386f5

Please sign in to comment.