From: kvigor Date: Tue, 17 Oct 2000 06:08:19 +0000 (+0000) Subject: avoid malloc(0) X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=ab6eab5b5988277004725e4c01238eea381dd571;p=fw%2Fsdcc avoid malloc(0) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@470 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/packihx/packihx.c b/packihx/packihx.c index 08d028e1..ad11efd7 100644 --- a/packihx/packihx.c +++ b/packihx/packihx.c @@ -144,8 +144,10 @@ Line *readLine(FILE *inFile) return NULL; } bp += 2; /* Two digits consumed. */ - - line->data = (Uint8 *)malloc(line->len); + + /* Hack - always allocate something, even if len is zero. + * Avoids special case for len == 0. */ + line->data = (Uint8 *)malloc(line->len ? line->len : 1); if (!line->data) { free(line);