Skip to content

Commit

Permalink
Merge pull request #7221 from gebart/pr/fmt-float-negative-bugfix
Browse files Browse the repository at this point in the history
sys/fmt: Fix unintentional pointer advancement for negative numbers in fmt_float
  • Loading branch information
kaspar030 authored Jun 22, 2017
2 parents 1014663 + 084db19 commit 02a3c9f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sys/fmt/fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -289,6 +288,7 @@ size_t fmt_float(char *out, float f, unsigned precision)
}
res += (1 + precision);
}
res += negative;

return res;
}
Expand Down

0 comments on commit 02a3c9f

Please sign in to comment.