]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_sip: Fix memory leaks.
authorCorey Farrell <git@cfware.com>
Tue, 19 Dec 2017 00:59:57 +0000 (19:59 -0500)
committerCorey Farrell <git@cfware.com>
Tue, 19 Dec 2017 19:47:26 +0000 (14:47 -0500)
In change_redirecting_information variables we use ast_strlen_zero to
see if a value should be saved.  In the case where the value is not NULL
but is a zero length string we leaked.

handle_response_subscribe leaked a reference to the ccss monitor
instance.

Change-Id: Ib11444de69c3d5b2360a88ba2feb54d2c2e9f05f

channels/chan_sip.c

index e54997b0d4e7c7410436e4a49566b7e731a6ac99..894bbf8a68dd3a5be2745e5cf19643a516ec4d55 100644 (file)
@@ -23430,6 +23430,8 @@ static void change_redirecting_information(struct sip_pvt *p, struct sip_request
                redirecting->from.number.valid = 1;
                ast_free(redirecting->from.number.str);
                redirecting->from.number.str = redirecting_from_number;
+       } else {
+               ast_free(redirecting_from_number);
        }
        if (!ast_strlen_zero(redirecting_from_name)) {
                ast_debug(3, "Got redirecting from name %s\n", redirecting_from_name);
@@ -23437,6 +23439,8 @@ static void change_redirecting_information(struct sip_pvt *p, struct sip_request
                redirecting->from.name.valid = 1;
                ast_free(redirecting->from.name.str);
                redirecting->from.name.str = redirecting_from_name;
+       } else {
+               ast_free(redirecting_from_name);
        }
        if (!ast_strlen_zero(p->cid_tag)) {
                ast_free(redirecting->from.tag);
@@ -23450,13 +23454,17 @@ static void change_redirecting_information(struct sip_pvt *p, struct sip_request
                redirecting->to.number.valid = 1;
                ast_free(redirecting->to.number.str);
                redirecting->to.number.str = redirecting_to_number;
+       } else {
+               ast_free(redirecting_to_number);
        }
        if (!ast_strlen_zero(redirecting_to_name)) {
-               ast_debug(3, "Got redirecting to name %s\n", redirecting_from_number);
+               ast_debug(3, "Got redirecting to name %s\n", redirecting_to_name);
                update_redirecting->to.name = 1;
                redirecting->to.name.valid = 1;
                ast_free(redirecting->to.name.str);
                redirecting->to.name.str = redirecting_to_name;
+       } else {
+               ast_free(redirecting_to_name);
        }
        redirecting->reason.code = reason;
        ast_free(redirecting->reason.str);
@@ -24486,6 +24494,7 @@ static void handle_response_subscribe(struct sip_pvt *p, int resp, const char *r
                        ast_cc_monitor_failed(monitor_instance->core_id,
                                monitor_instance->device_name,
                                "Received error response to our SUBSCRIBE");
+                       ao2_ref(monitor_instance, -1);
                }
                return;
        }