]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/stack_test.c: check sk_sint_push result in test_int_stack
authorEugene Syromiatnikov <esyr@openssl.org>
Tue, 12 Aug 2025 13:32:15 +0000 (15:32 +0200)
committerNeil Horman <nhorman@openssl.org>
Tue, 19 Aug 2025 18:47:54 +0000 (14:47 -0400)
coverity complains about possible double free, which does not seem
to be the case with the current implementation, but it still
would be nice to check and reacto on unexpected sk_sint_push result.

Complements: 9837496142cf "Unit tests for crypto/stack."
Resolves: https://scan5.scan.coverity.com/#/project-view/65249/10222?selectedIssue=1662046
Related: https://github.com/openssl/project/issues/1317
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28238)

test/stack_test.c

index d44e6fc93a309b0acbaf90265ebb8e16f0bd9a95..5ea84d5be27207b8ce613c76433954e4191ba5d6 100644 (file)
@@ -94,7 +94,10 @@ static int test_int_stack(int reserve)
             TEST_info("int stack size %d", i);
             goto end;
         }
-        sk_sint_push(s, v + i);
+        if (!TEST_int_eq(sk_sint_push(s, v + i), i + 1)) {
+            TEST_info("int stack size %d", i);
+            goto end;
+        }
     }
     if (!TEST_int_eq(sk_sint_num(s), n))
         goto end;