stasis_bridges.c: Fix off-nominal json memory leaks.
authorRichard Mudgett <rmudgett@digium.com>
Fri, 3 Nov 2017 23:08:37 +0000 (18:08 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Mon, 6 Nov 2017 18:11:04 +0000 (13:11 -0500)
Change-Id: Ib1181a36b317c86bff1ef2e44a17a0b1c73cfdc8

main/stasis_bridges.c

index 7f53bfe..d197e4d 100644 (file)
@@ -868,6 +868,8 @@ static struct ast_json *attended_transfer_to_json(struct stasis_message *msg,
        if (transfer_msg->transferee) {
                json_transferee = ast_channel_snapshot_to_json(transfer_msg->transferee, sanitize);
                if (!json_transferee) {
+                       ast_json_unref(json_transferer2);
+                       ast_json_unref(json_transferer1);
                        return NULL;
                }
        }
@@ -875,6 +877,9 @@ static struct ast_json *attended_transfer_to_json(struct stasis_message *msg,
        if (transfer_msg->target) {
                json_target = ast_channel_snapshot_to_json(transfer_msg->target, sanitize);
                if (!json_target) {
+                       ast_json_unref(json_transferee);
+                       ast_json_unref(json_transferer2);
+                       ast_json_unref(json_transferer1);
                        return NULL;
                }
        }
@@ -887,9 +892,12 @@ static struct ast_json *attended_transfer_to_json(struct stasis_message *msg,
                "result", result_strs[transfer_msg->result],
                "is_external", ast_json_boolean(transfer_msg->is_external));
        if (!out) {
+               ast_json_unref(json_target);
+               ast_json_unref(json_transferee);
                return NULL;
        }
        if (json_transferee && ast_json_object_set(out, "transferee", json_transferee)) {
+               ast_json_unref(json_target);
                return NULL;
        }
        if (json_target && ast_json_object_set(out, "transfer_target", json_target)) {