diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index e32a91759d..6830972698 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -416,7 +416,11 @@ int X509_verify_cert(X509_STORE_CTX *ctx) { } ctx->current_cert = x; } else { - sk_X509_push(ctx->chain, chain_ss); + if (!sk_X509_push(ctx->chain, chain_ss)) { + ctx->error = X509_V_ERR_OUT_OF_MEM; + ok = 0; + goto end; + } num++; ctx->last_untrusted = num; ctx->current_cert = chain_ss;