summaryrefslogtreecommitdiffstats
path: root/test/list_test.c
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2022-09-06 03:41:35 +0200
committerTomas Mraz <tomas@openssl.org>2022-09-07 11:49:32 +0200
commitfbeb4866f4250a4a23e7afb884a0aa0456d152f8 (patch)
tree691682bb57633a35fb60430fd92cbee71a394218 /test/list_test.c
parentInitial congestion control API design (diff)
downloadopenssl-fbeb4866f4250a4a23e7afb884a0aa0456d152f8.tar.xz
openssl-fbeb4866f4250a4a23e7afb884a0aa0456d152f8.zip
Coverity: explicit null dereference
Coverity is being pretty silly here but adding the explicit pointer checks will stop a crash if something goes badly awry. Fixes Coverity 1513706 - 1513709 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19136)
Diffstat (limited to 'test/list_test.c')
-rw-r--r--test/list_test.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/list_test.c b/test/list_test.c
index 5f89e5c6ad..908634d1f4 100644
--- a/test/list_test.c
+++ b/test/list_test.c
@@ -53,6 +53,10 @@ static int test_fizzbuzz(void)
if (!TEST_size_t_eq(ossl_list_fizz_num(&a), na)
|| !TEST_size_t_eq(ossl_list_buzz_num(&b), nb)
+ || !TEST_ptr(ossl_list_fizz_head(&a))
+ || !TEST_ptr(ossl_list_fizz_tail(&a))
+ || !TEST_ptr(ossl_list_buzz_head(&b))
+ || !TEST_ptr(ossl_list_buzz_tail(&b))
|| !TEST_int_eq(ossl_list_fizz_head(&a)->n, 3)
|| !TEST_int_eq(ossl_list_fizz_tail(&a)->n, na * 3)
|| !TEST_int_eq(ossl_list_buzz_head(&b)->n, nb * 5)
@@ -62,8 +66,12 @@ static int test_fizzbuzz(void)
ossl_list_buzz_remove(&b, ossl_list_buzz_tail(&b));
if (!TEST_size_t_eq(ossl_list_fizz_num(&a), --na)
|| !TEST_size_t_eq(ossl_list_buzz_num(&b), --nb)
+ || !TEST_ptr(ossl_list_fizz_head(&a))
+ || !TEST_ptr(ossl_list_buzz_tail(&b))
|| !TEST_int_eq(ossl_list_fizz_head(&a)->n, 6)
|| !TEST_int_eq(ossl_list_buzz_tail(&b)->n, 10)
+ || !TEST_ptr(ossl_list_fizz_next(ossl_list_fizz_head(&a)))
+ || !TEST_ptr(ossl_list_fizz_prev(ossl_list_fizz_tail(&a)))
|| !TEST_int_eq(ossl_list_fizz_next(ossl_list_fizz_head(&a))->n, 9)
|| !TEST_int_eq(ossl_list_fizz_prev(ossl_list_fizz_tail(&a))->n, 15))
return 0;
@@ -133,14 +141,18 @@ static int test_insert(void)
ossl_list_int_remove(&l, elem + 2); /* 3 4 5 */
ossl_list_int_remove(&l, elem + 4); /* 3 5 */
ossl_list_int_remove(&l, elem + 3); /* 5 */
- if (!TEST_int_eq(ossl_list_int_head(&l)->n, 5)
+ if (!TEST_ptr(ossl_list_int_head(&l))
+ || !TEST_ptr(ossl_list_int_tail(&l))
+ || !TEST_int_eq(ossl_list_int_head(&l)->n, 5)
|| !TEST_int_eq(ossl_list_int_tail(&l)->n, 5))
return 0;
/* Check removing the tail of a two element list works */
ossl_list_int_insert_head(&l, elem); /* 0 5 */
ossl_list_int_remove(&l, elem + 5); /* 0 */
- if (!TEST_int_eq(ossl_list_int_head(&l)->n, 0)
+ if (!TEST_ptr(ossl_list_int_head(&l))
+ || !TEST_ptr(ossl_list_int_tail(&l))
+ || !TEST_int_eq(ossl_list_int_head(&l)->n, 0)
|| !TEST_int_eq(ossl_list_int_tail(&l)->n, 0))
return 0;