Skip to content

Commit f6887f0

Browse files
committed
Fix memory leaks in openssl_cms_encrypt() when push fails
1 parent 556ec77 commit f6887f0

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

ext/openssl/openssl.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6464,7 +6464,10 @@ PHP_FUNCTION(openssl_cms_encrypt)
64646464
goto clean_exit;
64656465
}
64666466
}
6467-
sk_X509_push(recipcerts, cert);
6467+
if (sk_X509_push(recipcerts, cert) <= 0) {
6468+
php_openssl_store_errors();
6469+
goto clean_exit;
6470+
}
64686471
} ZEND_HASH_FOREACH_END();
64696472
} else {
64706473
/* a single certificate */
@@ -6484,7 +6487,10 @@ PHP_FUNCTION(openssl_cms_encrypt)
64846487
goto clean_exit;
64856488
}
64866489
}
6487-
sk_X509_push(recipcerts, cert);
6490+
if (sk_X509_push(recipcerts, cert) <= 0) {
6491+
php_openssl_store_errors();
6492+
goto clean_exit;
6493+
}
64886494
}
64896495

64906496
/* sanity check the cipher */

0 commit comments

Comments
 (0)