From 084db19107aafe084cf6ff0d8d3e950a82303b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Wed, 21 Jun 2017 18:21:55 +0200 Subject: [PATCH] sys/fmt: Fix unintentional pointer advancement for negative numbers in fmt_float --- sys/fmt/fmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/fmt/fmt.c b/sys/fmt/fmt.c index e2cc6c3a4df4..62e69cfc6ae3 100644 --- a/sys/fmt/fmt.c +++ b/sys/fmt/fmt.c @@ -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; }