forked from Mirrors/opensbi
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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user