File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -655,15 +655,16 @@ static int openssl_connect(git_stream *stream)
655655static int openssl_certificate (git_cert * * out , git_stream * stream )
656656{
657657 openssl_stream * st = (openssl_stream * ) stream ;
658- int len ;
659658 X509 * cert = SSL_get_peer_certificate (st -> ssl );
660- unsigned char * guard , * encoded_cert ;
659+ unsigned char * guard , * encoded_cert = NULL ;
660+ int error , len ;
661661
662662 /* Retrieve the length of the certificate first */
663663 len = i2d_X509 (cert , NULL );
664664 if (len < 0 ) {
665665 git_error_set (GIT_ERROR_NET , "failed to retrieve certificate information" );
666- return -1 ;
666+ error = -1 ;
667+ goto out ;
667668 }
668669
669670 encoded_cert = git__malloc (len );
@@ -673,18 +674,23 @@ static int openssl_certificate(git_cert **out, git_stream *stream)
673674
674675 len = i2d_X509 (cert , & guard );
675676 if (len < 0 ) {
676- git__free (encoded_cert );
677677 git_error_set (GIT_ERROR_NET , "failed to retrieve certificate information" );
678- return -1 ;
678+ error = -1 ;
679+ goto out ;
679680 }
680681
681682 st -> cert_info .parent .cert_type = GIT_CERT_X509 ;
682683 st -> cert_info .data = encoded_cert ;
683684 st -> cert_info .len = len ;
685+ encoded_cert = NULL ;
684686
685687 * out = & st -> cert_info .parent ;
688+ error = 0 ;
686689
687- return 0 ;
690+ out :
691+ git__free (encoded_cert );
692+ X509_free (cert );
693+ return error ;
688694}
689695
690696static int openssl_set_proxy (git_stream * stream , const git_proxy_options * proxy_opts )
You can’t perform that action at this time.
0 commit comments