Fix error handling in X509_chain_up_ref
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 16 Aug 2019 13:32:32 +0000 (15:32 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 16 Aug 2019 13:32:32 +0000 (15:32 +0200)
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/9615)

crypto/x509/x509_cmp.c

index 2d82f8fa8b2a6c3660dad6ddf8fa88f14c279ecb..a7b90e6a42f5a3312bad74ddd8753b1e95201cf1 100644 (file)
@@ -490,6 +490,8 @@ STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain)
     STACK_OF(X509) *ret;
     int i;
     ret = sk_X509_dup(chain);
+    if (ret == NULL)
+        return NULL;
     for (i = 0; i < sk_X509_num(ret); i++) {
         X509 *x = sk_X509_value(ret, i);
         CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);