File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ PHP NEWS
3535 . Fixed bug GH-16572 (Incorrect result with reflection in low-trigger JIT).
3636 (nielsdos)
3737
38+ - OpenSSL:
39+ . Fix various memory leaks on error conditions in openssl_x509_parse().
40+ (nielsdos)
41+
3842- PDO:
3943 . Fixed bug GH-16167 (Prevent mixing PDO sub-classes with different DSN).
4044 (kocsismate)
Original file line number Diff line number Diff line change @@ -2153,15 +2153,15 @@ PHP_FUNCTION(openssl_x509_parse)
21532153 /* Can return NULL on error or memory allocation failure */
21542154 if (!bn_serial ) {
21552155 php_openssl_store_errors ();
2156- RETURN_FALSE ;
2156+ goto err ;
21572157 }
21582158
21592159 hex_serial = BN_bn2hex (bn_serial );
21602160 BN_free (bn_serial );
21612161 /* Can return NULL on error or memory allocation failure */
21622162 if (!hex_serial ) {
21632163 php_openssl_store_errors ();
2164- RETURN_FALSE ;
2164+ goto err ;
21652165 }
21662166
21672167 str_serial = i2s_ASN1_INTEGER (NULL , asn1_serial );
@@ -2233,19 +2233,15 @@ PHP_FUNCTION(openssl_x509_parse)
22332233 bio_out = BIO_new (BIO_s_mem ());
22342234 if (bio_out == NULL ) {
22352235 php_openssl_store_errors ();
2236- RETURN_FALSE ;
2236+ goto err_subitem ;
22372237 }
22382238 if (nid == NID_subject_alt_name ) {
22392239 if (openssl_x509v3_subjectAltName (bio_out , extension ) == 0 ) {
22402240 BIO_get_mem_ptr (bio_out , & bio_buf );
22412241 add_assoc_stringl (& subitem , extname , bio_buf -> data , bio_buf -> length );
22422242 } else {
2243- zend_array_destroy (Z_ARR_P (return_value ));
22442243 BIO_free (bio_out );
2245- if (cert_str ) {
2246- X509_free (cert );
2247- }
2248- RETURN_FALSE ;
2244+ goto err_subitem ;
22492245 }
22502246 }
22512247 else if (X509V3_EXT_print (bio_out , extension , 0 , 0 )) {
@@ -2260,6 +2256,16 @@ PHP_FUNCTION(openssl_x509_parse)
22602256 if (cert_str ) {
22612257 X509_free (cert );
22622258 }
2259+ return ;
2260+
2261+ err_subitem :
2262+ zval_ptr_dtor (& subitem );
2263+ err :
2264+ zend_array_destroy (Z_ARR_P (return_value ));
2265+ if (cert_str ) {
2266+ X509_free (cert );
2267+ }
2268+ RETURN_FALSE ;
22632269}
22642270/* }}} */
22652271
You can’t perform that action at this time.
0 commit comments