mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/fmt: Fix unintentional pointer advancement for negative numbers in fmt_float
This commit is contained in:
parent
74d0c3b67a
commit
084db19107
@ -274,12 +274,11 @@ size_t fmt_float(char *out, float f, unsigned precision)
|
||||
|
||||
uint32_t fraction = f * _tenmap[precision];
|
||||
|
||||
size_t res = negative;
|
||||
if (negative && out) {
|
||||
*out++ = '-';
|
||||
}
|
||||
|
||||
res += fmt_u32_dec(out, integer);
|
||||
size_t res = fmt_u32_dec(out, integer);
|
||||
if (precision && fraction) {
|
||||
if (out) {
|
||||
out += res;
|
||||
@ -289,6 +288,7 @@ size_t fmt_float(char *out, float f, unsigned precision)
|
||||
}
|
||||
res += (1 + precision);
|
||||
}
|
||||
res += negative;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user