summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-22 11:42:35 +1000
committerPauli <ppzgs1@gmail.com>2021-03-24 09:12:43 +1000
commita60b533125c9316a8433b67ad8858d936fe2a426 (patch)
tree500e54a2ad8ba27ceb2744ffe1d8a597b2c68682 /crypto
parent711d7ca594ce86179df2c399fd2a6956f9939316 (diff)
err: fix coverity 1452768: dereference after null check
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14638)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/err/err_blocks.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/err/err_blocks.c b/crypto/err/err_blocks.c
index 0a2458f801..0e3ca14f72 100644
--- a/crypto/err/err_blocks.c
+++ b/crypto/err/err_blocks.c
@@ -92,7 +92,8 @@ void ERR_vset_error(int lib, int reason, const char *fmt, va_list args)
}
if (printed_len < 0)
printed_len = 0;
- buf[printed_len] = '\0';
+ if (buf != NULL)
+ buf[printed_len] = '\0';
/*
* Try to reduce the size, but only if we maximized above. If that
@@ -103,6 +104,7 @@ void ERR_vset_error(int lib, int reason, const char *fmt, va_list args)
if ((rbuf = OPENSSL_realloc(buf, printed_len + 1)) != NULL) {
buf = rbuf;
buf_size = printed_len + 1;
+ buf[printed_len] = '\0';
}
if (buf != NULL)