1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Don't emit the script destroyed signal before script is actually destroyed

The script unloading code originally worked like this:

1. Destroy package
2. Emit 'script destroyed' signal
3. Unhook script's signal handlers

If a script added a 'script destroyed' signal handler, unloading
that script would cause the 'script destroyed' signal to be sent to the
(already destroyed) package.  This would cause a script error, which would
trigger a script unload, which would start the whole process over again,
until we run out of heap or stack space and segfault.

This commit simply reorders the operations so that the 'script destroyed'
signal is sent *after* the script is fully destroyed.
This commit is contained in:
Stephen Oberholtzer 2017-02-28 23:48:56 -05:00
parent fa1a056291
commit 5c4e6304ce

View File

@ -67,11 +67,11 @@ static void perl_script_destroy(PERL_SCRIPT_REC *script)
{
perl_scripts = g_slist_remove(perl_scripts, script);
signal_emit("script destroyed", 1, script);
perl_signal_remove_script(script);
perl_source_remove_script(script);
signal_emit("script destroyed", 1, script);
g_free(script->name);
g_free(script->package);
g_free_not_null(script->path);