mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 06:10:56 +00:00
[util] Handle double shutdown
If Sys_Shutdown gets called twice, particularly if a shutdown callback hangs and the program is killed with INT or QUIT, shutdown_list would be in an invalid state. Thus, get the required data (function pointer and data pointer) from the list element, then unlink the element before calling the function. This ensures that a reinvocation of Sys_Shutdown continues from the next callback or ends cleanly. Fixes a segfault when killing testsound while using the oss output (it hangs on shutdown).
This commit is contained in:
parent
770187372d
commit
097d44e270
1 changed files with 4 additions and 1 deletions
|
@ -483,10 +483,13 @@ Sys_Shutdown (void)
|
|||
shutdown_list_t *t;
|
||||
|
||||
while (shutdown_list) {
|
||||
shutdown_list->func (shutdown_list->data);
|
||||
void (*func) (void *) = shutdown_list->func;
|
||||
void *data = shutdown_list->data;
|
||||
t = shutdown_list;
|
||||
shutdown_list = shutdown_list->next;
|
||||
free (t);
|
||||
|
||||
func (data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue