[sofia-sip] Fix memory leak when incomplete tls connection.

This commit is contained in:
Andrey Volk 2019-10-08 19:52:30 +04:00
parent dd1aab3332
commit 0af811bb24
3 changed files with 16 additions and 5 deletions

View File

@ -1 +1 @@
Fri Sep 20 12:16:57 CDT 2019
Tue Oct 08 10:50:11 CDT 2019

View 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;
}

View 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;
}