lib: sbi: Fix missing '\0' when buffer szie equal 1

Fix special case: sbi_snprintf(out, out_len, ...) when out_len equal
1, The previous code will not fill the buffer with any char.

Signed-off-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Xiang W 2023-07-10 00:03:26 +08:00 committed by Anup Patel
parent ff43168137
commit a73982d737

View file

@ -271,6 +271,12 @@ static int print(char **out, u32 *out_len, const char *format, va_list args)
out_len = &console_tbuf_len;
}
/* handle special case: *out_len == 1*/
if (out) {
if(!out_len || *out_len)
**out = '\0';
}
for (; *format != 0; ++format) {
width = flags = 0;
if (use_tbuf)