diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index e514ebeeaba59..01f7e73db5764 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -2166,6 +2166,12 @@ PHP_FUNCTION(openssl_x509_parse) } str_serial = i2s_ASN1_INTEGER(NULL, asn1_serial); + /* Can return NULL on error or memory allocation failure */ + if (!str_serial) { + php_openssl_store_errors(); + goto err; + } + add_assoc_string(return_value, "serialNumber", str_serial); OPENSSL_free(str_serial);