Skip to content

Commit 556ec77

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

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
@@ -5849,7 +5849,10 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
58495849
goto clean_exit;
58505850
}
58515851
}
5852-
sk_X509_push(recipcerts, cert);
5852+
if (sk_X509_push(recipcerts, cert) <= 0) {
5853+
X509_free(cert);
5854+
goto clean_exit;
5855+
}
58535856
} ZEND_HASH_FOREACH_END();
58545857
} else {
58555858
/* a single certificate */
@@ -5870,7 +5873,10 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
58705873
goto clean_exit;
58715874
}
58725875
}
5873-
sk_X509_push(recipcerts, cert);
5876+
if (sk_X509_push(recipcerts, cert) <= 0) {
5877+
X509_free(cert);
5878+
goto clean_exit;
5879+
}
58745880
}
58755881

58765882
/* sanity check the cipher */

0 commit comments

Comments
 (0)