Commits

tm512 committed c82339e

Fix double-free error in the seen module. Module deinit functions were able to be called twice, because sigdie could be called mutliple times. module_die didn't correctly free and set list reference to NULL.

Comments (0)

Files changed (1)

 
 void module_die (void)
 {
-	module_t *it = modules;
+	module_t *it = modules, *next;
 	moddeinit_f deinit;
 
 	while (it)
 	{
+		next = it->next;
+
 		deinit = (moddeinit_f) dlsym (it->mod, "deinit");
 		if (deinit)
 			deinit ();
 
-		it = it->next;
+		free (it);
+		it = next;
 	}
 
+	modules = NULL; // Don't run module_die again
+
 	return;
 }