[svn-commits] kmoore: branch mjordan/pjsip-cli r404435 - /team/mjordan/pjsip-cli/res/res_pj...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 20 13:56:37 CST 2013


Author: kmoore
Date: Fri Dec 20 13:56:35 2013
New Revision: 404435

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404435
Log:
Check for allocation failures

Modified:
    team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c

Modified: team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c?view=diff&rev=404435&r1=404434&r2=404435
==============================================================================
--- team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c (original)
+++ team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c Fri Dec 20 13:56:35 2013
@@ -1145,18 +1145,27 @@
 {
 	RAII_VAR(struct ao2_container *, parent_container, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, s_parent_container, NULL, ao2_cleanup);
-	RAII_VAR(struct ao2_container *, child_container, NULL, ao2_cleanup);
-
-	parent_container =  ast_sorcery_retrieve_by_fields(sip_sorcery, "endpoint",
+	struct ao2_container *child_container;
+
+	parent_container = ast_sorcery_retrieve_by_fields(sip_sorcery, "endpoint",
 				AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);
+	if (!parent_container) {
+		return NULL;
+	}
 
 	s_parent_container = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, &ast_sorcery_object_id_compare, NULL);
-
-	ao2_container_dup(s_parent_container, parent_container, OBJ_ORDER_ASCENDING);
+	if (!s_parent_container) {
+		return NULL;
+	}
+
+	if (ao2_container_dup(s_parent_container, parent_container, OBJ_ORDER_ASCENDING)) {
+		return NULL;
+	}
 
 	child_container = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL, NULL);
-
-	ao2_ref(child_container, +1);
+	if (!child_container) {
+		return NULL;
+	}
 
 	ao2_callback(s_parent_container, OBJ_NODATA, gather_endpoint_channels, child_container);
 
@@ -1205,6 +1214,7 @@
 	if (!(print_name = alloca(print_name_len))) {
 		return -1;
 	}
+
 	snprintf(print_name, print_name_len, "%s/%s", snapshot->name, snapshot->appl);
 
 	indent = CLI_INDENT_TO_SPACES(context->indent_level);
@@ -1339,14 +1349,14 @@
 	return 0;
 }
 
-static struct ast_sip_cli_formatter_entry  cli_channel_formatter = {
+static struct ast_sip_cli_formatter_entry cli_channel_formatter = {
 	.name = "channel",
 	.print_header = cli_print_channel_header,
 	.print_body = cli_print_channel_body,
 	.get_container = cli_get_channel_container,
 };
 
-static struct ast_sip_cli_formatter_entry  cli_endpoint_formatter = {
+static struct ast_sip_cli_formatter_entry cli_endpoint_formatter = {
 	.name = "endpoint",
 	.print_header = cli_print_endpoint_header,
 	.print_body = cli_print_endpoint_body,




More information about the svn-commits mailing list