Merge "res_pjsip: Fix transport_states ref leak"
authorFriendly Automation <jenkins2@gerrit.asterisk.org>
Thu, 11 Apr 2019 19:58:41 +0000 (14:58 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Thu, 11 Apr 2019 19:58:41 +0000 (14:58 -0500)
res/res_pjsip/pjsip_message_filter.c

index a144213..b70985b 100644 (file)
@@ -111,14 +111,13 @@ static pjsip_transport *get_udp_transport(pj_str_t *address, int port)
        }
 
        for (iter = ao2_iterator_init(transport_states, 0); (transport_state = ao2_iterator_next(&iter)); ao2_ref(transport_state, -1)) {
-               if (transport_state && ((transport_state->type != AST_TRANSPORT_UDP) ||
-                       (pj_strcmp(&transport_state->transport->local_name.host, address)) ||
-                       (transport_state->transport->local_name.port != port))) {
-                       continue;
+               if (transport_state->type == AST_TRANSPORT_UDP &&
+                       !pj_strcmp(&transport_state->transport->local_name.host, address) &&
+                       transport_state->transport->local_name.port == port) {
+                       sip_transport = transport_state->transport;
+                       ao2_ref(transport_state, -1);
+                       break;
                }
-
-               sip_transport = transport_state->transport;
-               break;
        }
        ao2_iterator_destroy(&iter);