]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[sofia-sip] Fix memory leak when incomplete tls connection.
authorAndrey Volk <andywolk@gmail.com>
Tue, 8 Oct 2019 15:52:30 +0000 (19:52 +0400)
committerAndrey Volk <andywolk@gmail.com>
Mon, 30 Dec 2019 20:49:50 +0000 (00:49 +0400)
libs/sofia-sip/.update
libs/sofia-sip/libsofia-sip-ua/tport/tport.c
libs/sofia-sip/libsofia-sip-ua/tport/tport_tls.c

index 4384659886d3723a8494dbff631c0d41b2dc48bf..d5e9004486a2581a07860a1d2d46fdfb884f1b64 100644 (file)
@@ -1 +1 @@
-Fri Sep 20 12:16:57 CDT 2019
+Tue Oct 08 10:50:11 CDT 2019
index 286de1a91e21149d77ee38c3956dfda2871186aa..68b401be23fac85ab8a34d146058b7c34f86478d 100644 (file)
@@ -1056,15 +1056,19 @@ int tport_register_secondary(tport_t *self, su_wakeup_f wakeup, int events)
       &&
       (i = su_root_register(root, wait, wakeup, self, 0)) != -1) {
 
+    /* Can't be added to list of opened if already closed */
+    if (tport_is_closed(self)) goto fail;
+
     self->tp_index = i;
     self->tp_events = events;
 
-       /* Can't be added to list of opened if already closed */
-       if (!tport_is_closed(self))
-               tprb_append(&self->tp_pri->pri_open, self);
+    tprb_append(&self->tp_pri->pri_open, self);
+
     return 0;
   }
 
+fail:
+  SU_DEBUG_9(("%s(%p): tport is %s!\n", __func__, (void *)self, (tport_is_closed(self) ? "closed" : "opened")));
   su_wait_destroy(wait);
   return -1;
 }
index f06aaaababe2a8e0d95e6f7d86a21dc6679882c9..8b079e91171559be031913d6a90f0d2015d5e988 100644 (file)
@@ -969,12 +969,19 @@ int tls_connect(su_root_magic_t *magic, su_wait_t *w, tport_t *self)
   if (events & SU_WAIT_HUP && !self->tp_closed)
     tport_hup_event(self);
 
-  if (self->tp_closed)
+  if (self->tp_closed) {
+    SU_DEBUG_9(("%s(%p): tport was closed during connect. Returning, but set secondary timer first.\n",
+                __func__, (void *)self));
+    tport_set_secondary_timer(self);
     return 0;
+  }
 
   error = su_soerror(self->tp_socket);
   if (error) {
     tport_error_report(self, error, NULL);
+    SU_DEBUG_9(("%s(%p): socket error during connect. Returning, but set secondary timer first.\n",
+                __func__, (void *)self));
+    tport_set_secondary_timer(self);
     return 0;
   }