summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshinomori <shinomori@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-27 13:41:03 +0000
committershinomori <shinomori@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-27 13:41:03 +0000
commitf1bf7e6f5619bb423440ff530c4d0f8a200d8aeb (patch)
tree12aa205e71c588c5d9842aae3b5170ff46cd8bde
parentc307cc46b9cb61aec87b899c153fce1b436ec8f3 (diff)
downloadhercules-f1bf7e6f5619bb423440ff530c4d0f8a200d8aeb.tar.gz
hercules-f1bf7e6f5619bb423440ff530c4d0f8a200d8aeb.tar.bz2
hercules-f1bf7e6f5619bb423440ff530c4d0f8a200d8aeb.tar.xz
hercules-f1bf7e6f5619bb423440ff530c4d0f8a200d8aeb.zip
do not access freed memory [Shinomori]
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1312 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--src/common/timer.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/common/timer.c b/src/common/timer.c
index 954582134..6bf5cdbda 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -294,11 +294,18 @@ int do_timer(unsigned int tick) {
void timer_final() {
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) {
- tfl2 = tfl;
- aFree(tfl->name);
+ tfl2 = tfl->next; // copy next pointer
+ aFree(tfl->name); // free structures
aFree(tfl);
- tfl = tfl2->next;
+ tfl = tfl2; // use copied pointer for next cycle
}
if (timer_data) aFree(timer_data);