]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
pbx_ael: unregister AELSub application and CLI commands on module load failure
authorAndreas Wehrmann <andreas-wehrmann@users.noreply.github.com>
Fri, 18 Apr 2025 08:56:05 +0000 (10:56 +0200)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 1 May 2025 12:39:48 +0000 (12:39 +0000)
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 aca78d493698acae12d0368c441faa359ce008a5)

pbx/pbx_ael.c

index 1a69fcd14a15fc428ef95ba76ebea64bc766ecc2..eeb873a20afa5ecdf087a881a4a61ef7f399e955 100644 (file)
@@ -274,11 +274,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)