From: Andreas Wehrmann Date: Fri, 18 Apr 2025 08:56:05 +0000 (+0200) Subject: pbx_ael: unregister AELSub application and CLI commands on module load failure X-Git-Tag: 21.9.0-rc1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ab473c973a27047b42c6b5343deb9ef19397f22;p=thirdparty%2Fasterisk.git pbx_ael: unregister AELSub application and CLI commands on module load failure This fixes crashes/hangs I noticed with Asterisk 20.3.0 and 20.13.0 and quickly found out, that the AEL module doesn't do proper cleanup when it fails to load. This happens for example when there are syntax errors and AEL fails to compile in which case pbx_load_module() returns an error but load_module() doesn't then unregister CLI cmds and the application. (cherry picked from commit c00e809ff0fd20e4b9a1a18ceddda47787a315c7) --- diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c index b254d0f400..442f3688aa 100644 --- a/pbx/pbx_ael.c +++ b/pbx/pbx_ael.c @@ -270,11 +270,21 @@ static int unload_module(void) static int load_module(void) { + int pbx_load_res = AST_MODULE_LOAD_SUCCESS; + ast_cli_register_multiple(cli_ael, ARRAY_LEN(cli_ael)); #ifndef STANDALONE ast_register_application_xml(aelsub, aelsub_exec); #endif - return (pbx_load_module()); + pbx_load_res = pbx_load_module(); + if (AST_MODULE_LOAD_SUCCESS != pbx_load_res) { +#ifndef STANDALONE + ast_unregister_application(aelsub); +#endif + ast_cli_unregister_multiple(cli_ael, ARRAY_LEN(cli_ael)); + } + + return pbx_load_res; } static int reload(void)