mirror of
https://github.com/Fishwaldo/opensbi.git
synced 2025-07-05 04:29:07 +00:00
lib: sbi: Fix printc
Because *out needs to reserve a byte to hold '\0', no more characters should be added to the buffer when *out has one byte left, and the buffer size *out_len should not be modified. this patch prevents the correction of *out_len when *out_len is 1. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
parent
3b6fcddceb
commit
cc89fa7b54
1 changed files with 2 additions and 3 deletions
|
@ -142,10 +142,9 @@ static void printc(char **out, u32 *out_len, char ch)
|
||||||
if (!out_len || *out_len > 1) {
|
if (!out_len || *out_len > 1) {
|
||||||
*(*out)++ = ch;
|
*(*out)++ = ch;
|
||||||
**out = '\0';
|
**out = '\0';
|
||||||
}
|
if (out_len)
|
||||||
|
|
||||||
if (out_len && *out_len > 0)
|
|
||||||
--(*out_len);
|
--(*out_len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prints(char **out, u32 *out_len, const char *string, int width,
|
static int prints(char **out, u32 *out_len, const char *string, int width,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue