Coverity 1515415: NULL dereference
authorPauli <pauli@openssl.org>
Sun, 18 Sep 2022 23:57:38 +0000 (09:57 +1000)
committerHugo Landau <hlandau@openssl.org>
Wed, 21 Sep 2022 13:16:47 +0000 (14:16 +0100)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19236)

(cherry picked from commit 82d46d14462491681f25d016508715e85c1dc4d1)

test/helpers/ssltestlib.c

index 24df80e0e9f6ceddf064d18b7d0d979e011dfc5f..51740f35999ea6cbca69ea1c5c12dca8c57052de 100644 (file)
@@ -504,7 +504,8 @@ int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum,
     }
 
     for (i = 0; i < sk_MEMPACKET_num(ctx->pkts); i++) {
-        looppkt = sk_MEMPACKET_value(ctx->pkts, i);
+        if (!TEST_ptr(looppkt = sk_MEMPACKET_value(ctx->pkts, i)))
+            goto err;
         /* Check if we found the right place to insert this packet */
         if (looppkt->num > thispkt->num) {
             if (sk_MEMPACKET_insert(ctx->pkts, thispkt, i) == 0)