From 7842240ebb099dfe068af7bd6543a94d273e1c3c Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Tue, 23 Oct 2018 19:20:32 +0200 Subject: [PATCH] When the offset is near the start we first search a bit further in the stream. --- MagickCore/magic.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MagickCore/magic.c b/MagickCore/magic.c index 15e946f2b..7dfa1cc49 100644 --- a/MagickCore/magic.c +++ b/MagickCore/magic.c @@ -167,7 +167,20 @@ static int CompareMagickInfoSize(const void *a,const void *b) ma=(MagicInfo *) a; mb=(MagicInfo *) b; if (ma->offset != mb->offset) - return((int) (ma->offset-mb->offset)); + { + MagickOffsetType + max_offset; + + /* + When the offset is near the start we first search a bit further + in the stream. + */ + max_offset=ma->offset > mb->offset ? ma->offset : mb->offset; + if (max_offset <= 10) + return((int) (mb->offset-ma->offset)); + else + return((int) (ma->offset-mb->offset)); + } return((int) (mb->length-ma->length)); } -- 2.40.0