]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 220365 via svnmerge from
authorDavid Vossel <dvossel@digium.com>
Thu, 24 Sep 2009 20:42:35 +0000 (20:42 +0000)
committerDavid Vossel <dvossel@digium.com>
Thu, 24 Sep 2009 20:42:35 +0000 (20:42 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

........
  r220365 | dvossel | 2009-09-24 15:37:20 -0500 (Thu, 24 Sep 2009) | 8 lines

  fixes tcptls_session memory leak caused by ref count error

  (closes issue #15939)
  Reported by: dvossel

  Review: https://reviewboard.asterisk.org/r/375/
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@220372 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/tcptls.c

index 64273ae0d14fe060883bee51f6ed9b764d595894..66a1abd65cd007c81ac211e14c64f32d29da609c 100644 (file)
@@ -276,7 +276,6 @@ struct ast_tcptls_session_instance *ast_tcptls_client_start(struct server_args *
                __ssl_setup(desc->tls_cfg, 1);
        }
 
-       ao2_ref(tcptls_session, +1);
        if (!ast_make_file_from_fd(tcptls_session))
                goto error;
 
@@ -374,6 +373,8 @@ void ast_tcptls_server_stop(struct server_args *desc)
 * creates a FILE * from the fd passed by the accept thread.
 * This operation is potentially expensive (certificate verification),
 * so we do it in the child thread context.
+*
+* \note must decrement ref count before returning NULL on error
 */
 void *ast_make_file_from_fd(void *data)
 {
@@ -448,6 +449,7 @@ void *ast_make_file_from_fd(void *data)
                                                if (peer)
                                                        X509_free(peer);
                                                fclose(tcptls_session->f);
+                                               ao2_ref(tcptls_session, -1);
                                                return NULL;
                                        }
                                }