@@ -1495,7 +1495,7 @@ PHP_FUNCTION(openssl_x509_export_to_file)
14951495 }
14961496
14971497 if (!php_openssl_check_path (filename , filename_len , file_path , 2 )) {
1498- return ;
1498+ goto exit_cleanup_cert ;
14991499 }
15001500
15011501 bio_out = BIO_new_file (file_path , PHP_OPENSSL_BIO_MODE_W (PKCS7_BINARY ));
@@ -1513,13 +1513,14 @@ PHP_FUNCTION(openssl_x509_export_to_file)
15131513 php_error_docref (NULL , E_WARNING , "Error opening file %s" , file_path );
15141514 }
15151515
1516- if (cert_str ) {
1517- X509_free (cert );
1518- }
1519-
15201516 if (!BIO_free (bio_out )) {
15211517 php_openssl_store_errors ();
15221518 }
1519+
1520+ exit_cleanup_cert :
1521+ if (cert_str ) {
1522+ X509_free (cert );
1523+ }
15231524}
15241525/* }}} */
15251526
@@ -3070,7 +3071,7 @@ PHP_FUNCTION(openssl_csr_export_to_file)
30703071 }
30713072
30723073 if (!php_openssl_check_path (filename , filename_len , file_path , 2 )) {
3073- return ;
3074+ goto exit_cleanup ;
30743075 }
30753076
30763077 bio_out = BIO_new_file (file_path , PHP_OPENSSL_BIO_MODE_W (PKCS7_BINARY ));
@@ -3090,6 +3091,7 @@ PHP_FUNCTION(openssl_csr_export_to_file)
30903091 php_error_docref (NULL , E_WARNING , "Error opening file %s" , file_path );
30913092 }
30923093
3094+ exit_cleanup :
30933095 if (csr_str ) {
30943096 X509_REQ_free (csr );
30953097 }
@@ -4567,7 +4569,7 @@ PHP_FUNCTION(openssl_pkey_export_to_file)
45674569 }
45684570
45694571 if (!php_openssl_check_path (filename , filename_len , file_path , 2 )) {
4570- RETURN_FALSE ;
4572+ goto clean_exit_key ;
45714573 }
45724574
45734575 PHP_SSL_REQ_INIT (& req );
@@ -4603,8 +4605,9 @@ PHP_FUNCTION(openssl_pkey_export_to_file)
46034605
46044606clean_exit :
46054607 PHP_SSL_REQ_DISPOSE (& req );
4606- EVP_PKEY_free (key );
46074608 BIO_free (bio_out );
4609+ clean_exit_key :
4610+ EVP_PKEY_free (key );
46084611}
46094612/* }}} */
46104613
0 commit comments