@@ -1508,7 +1508,7 @@ PHP_FUNCTION(openssl_pkcs12_read)
15081508
15091509 if (cert ) {
15101510 bio_out = BIO_new (BIO_s_mem ());
1511- if (PEM_write_bio_X509 (bio_out , cert )) {
1511+ if (bio_out && PEM_write_bio_X509 (bio_out , cert )) {
15121512 BUF_MEM * bio_buf ;
15131513 BIO_get_mem_ptr (bio_out , & bio_buf );
15141514 ZVAL_STRINGL (& zcert , bio_buf -> data , bio_buf -> length );
@@ -1521,7 +1521,7 @@ PHP_FUNCTION(openssl_pkcs12_read)
15211521
15221522 if (pkey ) {
15231523 bio_out = BIO_new (BIO_s_mem ());
1524- if (PEM_write_bio_PrivateKey (bio_out , pkey , NULL , NULL , 0 , 0 , NULL )) {
1524+ if (bio_out && PEM_write_bio_PrivateKey (bio_out , pkey , NULL , NULL , 0 , 0 , NULL )) {
15251525 BUF_MEM * bio_buf ;
15261526 BIO_get_mem_ptr (bio_out , & bio_buf );
15271527 ZVAL_STRINGL (& zpkey , bio_buf -> data , bio_buf -> length );
@@ -1542,7 +1542,7 @@ PHP_FUNCTION(openssl_pkcs12_read)
15421542 if (!aCA ) break ;
15431543
15441544 bio_out = BIO_new (BIO_s_mem ());
1545- if (PEM_write_bio_X509 (bio_out , aCA )) {
1545+ if (bio_out && PEM_write_bio_X509 (bio_out , aCA )) {
15461546 BUF_MEM * bio_buf ;
15471547 BIO_get_mem_ptr (bio_out , & bio_buf );
15481548 ZVAL_STRINGL (& zextracert , bio_buf -> data , bio_buf -> length );
@@ -2206,6 +2206,10 @@ PHP_FUNCTION(openssl_pkey_export)
22062206
22072207 if (PHP_SSL_REQ_PARSE (& req , args ) == SUCCESS ) {
22082208 bio_out = BIO_new (BIO_s_mem ());
2209+ if (!bio_out ) {
2210+ php_openssl_store_errors ();
2211+ goto cleanup ;
2212+ }
22092213
22102214 if (passphrase && req .priv_key_encrypt ) {
22112215 if (req .priv_key_encrypt_cipher ) {
@@ -2234,6 +2238,7 @@ PHP_FUNCTION(openssl_pkey_export)
22342238 php_openssl_store_errors ();
22352239 }
22362240 }
2241+ cleanup :
22372242 EVP_PKEY_free (key );
22382243 BIO_free (bio_out );
22392244 PHP_SSL_REQ_DISPOSE (& req );
@@ -4492,7 +4497,8 @@ PHP_FUNCTION(openssl_digest)
44924497 sigbuf = zend_string_alloc (siglen , 0 );
44934498
44944499 md_ctx = EVP_MD_CTX_create ();
4495- if (EVP_DigestInit (md_ctx , mdtype ) &&
4500+ if (md_ctx &&
4501+ EVP_DigestInit (md_ctx , mdtype ) &&
44964502 EVP_DigestUpdate (md_ctx , (unsigned char * )data , data_len ) &&
44974503 EVP_DigestFinal (md_ctx , (unsigned char * )ZSTR_VAL (sigbuf ), & siglen )) {
44984504 if (raw_output ) {
0 commit comments