From a106391d2eb69aac1c3ab7f58e215c89ddfc733f Mon Sep 17 00:00:00 2001 From: "zik.saleeba" Date: Thu, 30 Aug 2012 10:18:36 +0000 Subject: [PATCH] Fixed a crash when printf() formats are set as 0 (NULL). git-svn-id: http://picoc.googlecode.com/svn/trunk@576 21eae674-98b7-11dd-bd71-f92a316d2d60 --- cstdlib/stdio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cstdlib/stdio.c b/cstdlib/stdio.c index fef46ac..893aecc 100644 --- a/cstdlib/stdio.c +++ b/cstdlib/stdio.c @@ -186,12 +186,16 @@ int StdioBasePrintf(struct ParseState *Parser, FILE *Stream, char *StrOut, int S { struct Value *ThisArg = Args->Param[0]; int ArgCount = 0; - char *FPos = Format; + char *FPos; char OneFormatBuf[MAX_FORMAT+1]; int OneFormatCount; struct ValueType *ShowType; StdOutStream SOStream; + if (Format == NULL) + Format = "[null format]\n"; + + FPos = Format; SOStream.FilePtr = Stream; SOStream.StrOutPtr = StrOut; SOStream.StrOutLen = StrOutLen;