diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-11-05 18:20:09 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-11-05 18:20:09 +0000 |
commit | 94daf932608f2a993e71e76ff293eec97b677c6a (patch) | |
tree | 9a9a62f6cf1cc22fda3fd1ab473409c33809b54f /regress/lib/libcrypto/bn | |
parent | e11da570fad04bff3f6e6779c55a0eb89046794f (diff) |
bn_convert: avoid a zero-sized allocation
Diffstat (limited to 'regress/lib/libcrypto/bn')
-rw-r--r-- | regress/lib/libcrypto/bn/bn_convert.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/regress/lib/libcrypto/bn/bn_convert.c b/regress/lib/libcrypto/bn/bn_convert.c index e7d6138f36a..d122915667d 100644 --- a/regress/lib/libcrypto/bn/bn_convert.c +++ b/regress/lib/libcrypto/bn/bn_convert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_convert.c,v 1.8 2024/11/03 12:47:49 jsing Exp $ */ +/* $OpenBSD: bn_convert.c,v 1.9 2024/11/05 18:20:08 tb Exp $ */ /* * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> * @@ -55,7 +55,7 @@ check_bin_output(size_t test_no, const char *label, const uint8_t *bin, "want %zu\n", test_no, label, out_len, bin_len); goto failure; } - if ((out = malloc(out_len)) == NULL) + if (out_len > 0 && (out = malloc(out_len)) == NULL) err(1, "malloc"); if ((ret = BN_bn2bin(bn, out)) != out_len) { fprintf(stderr, "FAIL: Test %zu %s - BN_bn2bin() returned %d, " |