mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-13 11:47:00 +08:00
lwip_itoa: fix converting 0 (bug #51729)
lwip_itoa would output the number 0 as \0. This fixes the issue by adding a special check before the normal conversion loop This was found via shell cmd idxtoname and win32 port. "lo0" should be returned for index 1
This commit is contained in:
@@ -217,6 +217,11 @@ lwip_itoa(char* result, size_t bufsize, int number)
|
||||
/* create the string in a temporary buffer since we don't know how long
|
||||
it will get */
|
||||
tmp = &result[bufsize-2];
|
||||
if (n == 0) {
|
||||
*tmp = '0';
|
||||
tmp--;
|
||||
result_len++;
|
||||
}
|
||||
while ((n != 0) && (result_len < (bufsize - 1))) {
|
||||
char val = (char)('0' + (n % 10));
|
||||
*tmp = val;
|
||||
|
||||
Reference in New Issue
Block a user