do not access freed memory [Shinomori]

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1312 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
shinomori 2005-03-27 13:41:03 +00:00
parent 06661cb573
commit e2b4dfda4e

View File

@ -294,11 +294,18 @@ int do_timer(unsigned int tick) {
void timer_final() { void timer_final() {
struct timer_func_list* tfl = tfl_root, *tfl2; struct timer_func_list* tfl = tfl_root, *tfl2;
// while (tfl) {
// tfl2 = tfl;
// aFree(tfl->name);
// aFree(tfl);
// tfl = tfl2->next; // access on already freed memory
// }
while (tfl) { while (tfl) {
tfl2 = tfl; tfl2 = tfl->next; // copy next pointer
aFree(tfl->name); aFree(tfl->name); // free structures
aFree(tfl); aFree(tfl);
tfl = tfl2->next; tfl = tfl2; // use copied pointer for next cycle
} }
if (timer_data) aFree(timer_data); if (timer_data) aFree(timer_data);