[asterisk-commits] dlee: branch dlee/allow-multiple r395412 - /team/dlee/allow-multiple/res/stas...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 25 11:01:10 CDT 2013


Author: dlee
Date: Thu Jul 25 11:01:08 2013
New Revision: 395412

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395412
Log:
Bridging fixes

Modified:
    team/dlee/allow-multiple/res/stasis_http/resource_bridges.c

Modified: team/dlee/allow-multiple/res/stasis_http/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/allow-multiple/res/stasis_http/resource_bridges.c?view=diff&rev=395412&r1=395411&r2=395412
==============================================================================
--- team/dlee/allow-multiple/res/stasis_http/resource_bridges.c (original)
+++ team/dlee/allow-multiple/res/stasis_http/resource_bridges.c Thu Jul 25 11:01:08 2013
@@ -109,7 +109,7 @@
 
 struct control_list {
 	size_t count;
-	struct stasis_app_control **controls;
+	struct stasis_app_control *controls[];
 };
 
 static void control_list_dtor(void *obj) {
@@ -126,22 +126,32 @@
 	RAII_VAR(struct control_list *, list, NULL, ao2_cleanup);
 	size_t i;
 
-	if (count <= 0 || !channels) {
+	if (count == 0 || !channels) {
 		stasis_http_response_error(response, 400, "Bad Request", "Missing parameter channel");
 		return NULL;
 	}
 
-	list = ao2_alloc(sizeof(*list), control_list_dtor);
+	list = ao2_alloc(sizeof(*list) + count * sizeof(list->controls[0]), control_list_dtor);
 	if (!list) {
 		stasis_http_response_alloc_failed(response);
 		return NULL;
 	}
 
 	for (i = 0; i < count; ++i) {
-		list->controls[i] = find_channel_control(response, channels[i]);
-		if (!list->controls[i]) {
+		if (ast_strlen_zero(channels[i])) {
+			continue;
+		}
+		list->controls[list->count] =
+			find_channel_control(response, channels[i]);
+		if (!list->controls[list->count]) {
 			return NULL;
 		}
+		++list->count;
+	}
+
+	if (list->count == 0) {
+		stasis_http_response_error(response, 400, "Bad Request", "Missing parameter channel");
+		return NULL;
 	}
 
 	ao2_ref(list, +1);




More information about the asterisk-commits mailing list