Problems with zero precision
Opened this issue · 2 comments
Deleted user commented
There are some problems with a precision of 0 (an annoying corner case).
The following crash:
printf("% .0d", 0);
(should outputprintf("%+.0d", 0);
(should output+
)
This is caused by decrementing a 0 len
here: https://github.com/mpaland/printf/blob/master/printf.c#L185
printf("%#.0x", 0);
is apparently supposed to output an empty string, not 0x
. The octal case is correct, though. It seems this was clarified in C11.
mpaland commented
Wow! This is really serious and leads to out of bounds buffer access!
Wondering that coverity didn't catch it.