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.
This commit is contained in:
Stephen Oberholtzer 2017-03-14 16:27:18 -04:00
commit bbf52fa7fa

View file

@ -191,9 +191,9 @@ static void cmd_set(char *data)
/* Unpossible! */ /* Unpossible! */
break; break;
} }
signal_emit("setup changed", 0);
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_SET_TITLE, rec->section); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_SET_TITLE, rec->section);
set_print(rec); set_print(rec);
signal_emit("setup changed", 0);
} else } else
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_SET_UNKNOWN, key); printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_SET_UNKNOWN, key);
} }