From d58297a61adcc4df4d5e916525f669f8bb886c99 Mon Sep 17 00:00:00 2001 From: Christos Zoulas <christos@zoulas.com> Date: Thu, 9 Aug 2012 16:33:15 +0000 Subject: [PATCH] avoid malloc(0) on aix. (Lorinczy Zsigmond) --- src/ascmagic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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. */ -- 2.40.0