From bbf52fa7fa599018deb2beeaeee601357932d277 Mon Sep 17 00:00:00 2001 From: Stephen Oberholtzer Date: Tue, 14 Mar 2017 16:27:18 -0400 Subject: [PATCH] Send 'setup changed' event after we echo the new setting If the setting was created by a Perl script, and an error occurs while processing the 'setup changed' signal, the Perl script will unload and destroy the SETTINGS_REC out from under us, causing a use-after-free and likely a segfault. This commit reorders the calls so that the 'setup changed' signal happens last. As an added bonus, any output generated by any module or script in response to the new setting will show up *after* we confirm the setting change, rather than before. --- src/fe-common/core/fe-settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index abbd45a8..f1706d23 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -191,9 +191,9 @@ static void cmd_set(char *data) /* Unpossible! */ break; } - signal_emit("setup changed", 0); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_SET_TITLE, rec->section); set_print(rec); + signal_emit("setup changed", 0); } else printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_SET_UNKNOWN, key); }