Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14638)
}
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
if ((rbuf = OPENSSL_realloc(buf, printed_len + 1)) != NULL) {
buf = rbuf;
buf_size = printed_len + 1;
+ buf[printed_len] = '\0';
}
if (buf != NULL)