C library shipping with TI ARM compiler 5.2.8 handles NULL string pointers passed to the printf family if functions incorrectly.
The bug is in arm_5.2.8/lib/src/_printfi.c, in _pproc_str, line 482:
/*------------------------------------------------------------------------*/
/* Handle NULL strings. */
/*------------------------------------------------------------------------*/
if (strbuf == NULL)
{
_outc('\0', _op);
return;
}
The way it "handles" NULL strings is by inserting a NUL character, which is wrong. Other C libraries either emit nothing or a predefined string, usually "(null)" or some such.
here's a test code snippet:
char buf[100];
const char *s = NULL;
int n = sprintf(buf, "Hello '%s' '%.*s'!", s, 0, s);
printf("\n%d >%s<\n", n, buf);
on a GNU C library it produces
18 >Hello '(null)' ''!<
On TI library it produces
12 >Hello '<
Also note the behavior when %.* format is used - GNU libc handles it correctly and does not output anything in this case