aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc
diff options
context:
space:
mode:
authorIgor Petrov <igor.petrov.dev@pm.me>2025-03-13 19:23:04 +0000
committerCorinna Vinschen <corinna@vinschen.de>2025-03-14 17:05:21 +0100
commit1409c7872f5755d0770dffaaa57aa583e64196f4 (patch)
tree896246276fd143288243b190fd9353b8e2e7359b /newlib/libc
parent0f02ac19102dd8e5c5722cac2f6069e646f0f42c (diff)
downloadnewlib-1409c7872f5755d0770dffaaa57aa583e64196f4.zip
newlib-1409c7872f5755d0770dffaaa57aa583e64196f4.tar.gz
newlib-1409c7872f5755d0770dffaaa57aa583e64196f4.tar.bz2
newlib: fix uninitialized character count being used when printing float without "_printf_float" being linked
Patch fixes wrong number of written characters being returend from 'printf' family of functionsx when '_printf_float' is not linked (nano.specs). If user tries to print a floating point number anyway, returned number of written characters is not correct. For example in printf("%d%f", 1, 1.0); should return 1, but actaully returns 2.
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/machine/msp430/tiny-printf.c1
-rw-r--r--newlib/libc/stdio/nano-vfprintf.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/newlib/libc/machine/msp430/tiny-printf.c b/newlib/libc/machine/msp430/tiny-printf.c
index f2412a0..b5ad528 100644
--- a/newlib/libc/machine/msp430/tiny-printf.c
+++ b/newlib/libc/machine/msp430/tiny-printf.c
@@ -237,6 +237,7 @@ __tiny_vfprintf_r (struct _reent *data,
GET_ARG (N, ap_copy, _LONG_DOUBLE);
else
GET_ARG (N, ap_copy, double);
+ n = 0;
}
else
n = _printf_float (data, &prt_data, fp, pfunc, &ap_copy);
diff --git a/newlib/libc/stdio/nano-vfprintf.c b/newlib/libc/stdio/nano-vfprintf.c
index 0d42a94..bdcc9b2 100644
--- a/newlib/libc/stdio/nano-vfprintf.c
+++ b/newlib/libc/stdio/nano-vfprintf.c
@@ -627,6 +627,7 @@ _VFPRINTF_R (struct _reent *data,
GET_ARG (N, ap_copy, _LONG_DOUBLE);
else
GET_ARG (N, ap_copy, double);
+ n = 0;
}
else
n = _printf_float (data, &prt_data, fp, pfunc, &ap_copy);