summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorx2018 <xkernel.wang@foxmail.com>2021-11-01 20:36:54 +0800
committerTomas Mraz <tomas@openssl.org>2021-11-03 14:29:48 +0100
commitafbea17ded816aba6d7106671b405de82da5c6f3 (patch)
tree47ce9db78a5a747c38372626fbde80045236ccbc /test
parent886e6855c3fd5ea977b36afea5a2aa31b7cdd01c (diff)
check the return value of BN_new() and BN_dup()
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16948) (cherry picked from commit d99004fe5de934120765d342586f08d22131b8ed)
Diffstat (limited to 'test')
-rw-r--r--test/testutil/tests.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/testutil/tests.c b/test/testutil/tests.c
index a60af0764f..bd05f34250 100644
--- a/test/testutil/tests.c
+++ b/test/testutil/tests.c
@@ -393,8 +393,8 @@ int test_BN_eq_word(const char *file, int line, const char *bns, const char *ws,
if (a != NULL && BN_is_word(a, w))
return 1;
- bw = BN_new();
- BN_set_word(bw, w);
+ if ((bw = BN_new()) != NULL)
+ BN_set_word(bw, w);
test_fail_bignum_message(NULL, file, line, "BIGNUM", bns, ws, "==", a, bw);
BN_free(bw);
return 0;
@@ -407,10 +407,10 @@ int test_BN_abs_eq_word(const char *file, int line, const char *bns,
if (a != NULL && BN_abs_is_word(a, w))
return 1;
- bw = BN_new();
- aa = BN_dup(a);
- BN_set_negative(aa, 0);
- BN_set_word(bw, w);
+ if ((aa = BN_dup(a)) != NULL)
+ BN_set_negative(aa, 0);
+ if ((bw = BN_new()) != NULL)
+ BN_set_word(bw, w);
test_fail_bignum_message(NULL, file, line, "BIGNUM", bns, ws, "abs==",
aa, bw);
BN_free(bw);