res_pjsip: Fix transport_states ref leak
authorAlexei Gradinari <alex2grad@gmail.com>
Tue, 9 Apr 2019 21:47:59 +0000 (17:47 -0400)
committerAlexei Gradinari <alex2grad@gmail.com>
Wed, 10 Apr 2019 14:37:49 +0000 (08:37 -0600)
Add missing ao2_ref(transport_state, -1) while iterate on a transport_states
container.

Change-Id: I40e35b5a339121300c80075c30db47201a6c374e

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);