فهرست منبع

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
shinomori 20 سال پیش
والد
کامیت
e2b4dfda4e
1فایلهای تغییر یافته به همراه10 افزوده شده و 3 حذف شده
  1. 10 3
      src/common/timer.c

+ 10 - 3
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);