From 8f3cee125816486875c7d7d12dcf02dbf2b642d1 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Fri, 1 May 2015 14:22:03 -0400 Subject: Astobj2: Fix initialization order of refdebug and AO2_DEBUG. This ensures that refdebug is initialized before AO2_DEBUG if both are enabled, since AO2_DEBUG allocates a container. This change also makes AO2_DEBUG initialization critical, a failure will abort Asterisk startup. This is needed since the failure would be caused by reg_containers allocation failure, and that would result in a segmentation fault by ao2_container_register later in startup. ASTERISK-25048 #close Reported by: Corey Farrell Change-Id: I9a243ea3fc5653b48b931ba6d61971cb2e530244 --- main/astobj2.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'main/astobj2.c') diff --git a/main/astobj2.c b/main/astobj2.c index f9dd8d490..1db2dd42d 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -1143,10 +1143,6 @@ int astobj2_init(void) { char ref_filename[1024]; - if (container_init() != 0) { - return -1; - } - if (ast_opt_ref_debug) { snprintf(ref_filename, sizeof(ref_filename), "%s/refs", ast_config_AST_LOG_DIR); ref_log = fopen(ref_filename, "w"); @@ -1155,6 +1151,11 @@ int astobj2_init(void) } } + if (container_init() != 0) { + fclose(ref_log); + return -1; + } + #if defined(AO2_DEBUG) ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); #endif /* defined(AO2_DEBUG) */ -- cgit v1.2.3