Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 375940) +++ channels/chan_sip.c (working copy) @@ -2585,11 +2585,13 @@ size_t bytes_read; if (!tcptls_session->client && !authenticated) { if ((timeout = sip_check_authtimeout(start)) < 0) { + deinit_req(&reqcpy); return -1; } if (timeout == 0) { ast_debug(2, "SIP SSL server timed out\n"); + deinit_req(&reqcpy); return -1; } } else { @@ -2602,10 +2604,12 @@ res = ast_wait_for_input(tcptls_session->fd, timeout); if (res < 0) { ast_debug(2, "SIP TCP server :: ast_wait_for_input returned %d\n", res); + deinit_req(&reqcpy); return -1; } else if (res == 0) { /* timeout */ ast_debug(2, "SIP TCP server timed out\n"); + deinit_req(&reqcpy); return -1; } } @@ -2614,6 +2618,7 @@ if (!(bytes_read = fread(buf, 1, MIN(sizeof(buf) - 1, content_length), tcptls_session->f))) { ast_mutex_unlock(&tcptls_session->lock); if (after_poll) { + deinit_req(&reqcpy); return -1; } else { need_poll = 1; @@ -2624,6 +2629,7 @@ ast_mutex_unlock(&tcptls_session->lock); after_poll = 0; if (me->stop) { + deinit_req(&reqcpy); return -1; } content_length -= strlen(buf); @@ -2632,6 +2638,7 @@ } /*! \todo XXX If there's no Content-Length or if the content-length and what we receive is not the same - we should generate an error */ + deinit_req(&reqcpy); return 0; }