diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -357,7 +357,8 @@ pfatal_with_name (const char *name) char * xmalloc (unsigned int size) { - char *result = (char *) malloc (size); + /* Make sure we don't allocate 0, for pre-ANSI libraries. */ + char *result = (char *) malloc (size ? size : 1); if (result == 0) fatal (NILF, _("virtual memory exhausted")); return result; @@ -370,6 +371,8 @@ xrealloc (char *ptr, unsigned int size) char *result; /* Some older implementations of realloc() don't conform to ANSI. */ + if (! size) + size = 1; result = ptr ? realloc (ptr, size) : malloc (size); if (result == 0) fatal (NILF, _("virtual memory exhausted")); |