mirror of
https://github.com/Fishwaldo/opensbi.git
synced 2025-03-15 19:31:32 +00:00
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:
parent
ff43168137
commit
a73982d737
1 changed files with 6 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue