From: Pauli Date: Mon, 22 Mar 2021 01:42:35 +0000 (+1000) Subject: err: fix coverity 1452768: dereference after null check X-Git-Tag: openssl-3.0.0-alpha14~165 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a60b533125c9316a8433b67ad8858d936fe2a426;p=thirdparty%2Fopenssl.git err: fix coverity 1452768: dereference after null check Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14638) --- diff --git a/crypto/err/err_blocks.c b/crypto/err/err_blocks.c index 0a2458f8014..0e3ca14f727 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)