avoid malloc(0)
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 17 Oct 2000 06:08:19 +0000 (06:08 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 17 Oct 2000 06:08:19 +0000 (06:08 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@470 4a8a32a2-be11-0410-ad9d-d568d2c75423

packihx/packihx.c

index 08d028e162da3388ff0ded0e770d2bc5732d8f19..ad11efd7050f2685fc87b45ac87e1ded67cef884 100644 (file)
@@ -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);