diff options
Diffstat (limited to 'stdio-common')
-rw-r--r-- | stdio-common/tst-sprintf.c | 19 | ||||
-rw-r--r-- | stdio-common/vfprintf.c | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/stdio-common/tst-sprintf.c b/stdio-common/tst-sprintf.c new file mode 100644 index 0000000000..afbacd9037 --- /dev/null +++ b/stdio-common/tst-sprintf.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <string.h> + + +int +main (void) +{ + char buf[100]; + int result = 0; + + if (sprintf (buf, "%.0ls", L"foo") != 0 + || strlen (buf) != 0) + { + puts ("sprintf (buf, \"%.0ls\", L\"foo\") produced some output\n"); + result = 1; + } + + return result; +} diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c index c5e78c7499..febd094729 100644 --- a/stdio-common/vfprintf.c +++ b/stdio-common/vfprintf.c @@ -1195,7 +1195,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap) \ memset (&mbstate, '\0', sizeof (mbstate_t)); \ \ - if (prec > 0) \ + if (prec >= 0) \ { \ /* The string `s2' might not be NUL terminated. */ \ if (prec < 32768 \ |