From: Christos Zoulas Date: Thu, 9 Aug 2012 16:33:15 +0000 (+0000) Subject: avoid malloc(0) on aix. (Lorinczy Zsigmond) X-Git-Tag: FILE5_12~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d58297a61adcc4df4d5e916525f669f8bb886c99;p=file avoid malloc(0) on aix. (Lorinczy Zsigmond) --- diff --git a/src/ascmagic.c b/src/ascmagic.c index 18fa9356..325678da 100644 --- a/src/ascmagic.c +++ b/src/ascmagic.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: ascmagic.c,v 1.83 2011/12/08 12:12:46 rrt Exp $") +FILE_RCSID("@(#)$File: ascmagic.c,v 1.84 2011/12/08 12:38:24 rrt Exp $") #endif /* lint */ #include "magic.h" @@ -134,7 +134,7 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf, goto done; } - if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0) { + if (ulen > 0 && (ms->flags & MAGIC_NO_CHECK_SOFT) == 0) { /* Convert ubuf to UTF-8 and try text soft magic */ /* malloc size is a conservative overestimate; could be improved, or at least realloced after conversion. */