From: Dirk Lemstra Date: Tue, 23 Oct 2018 17:20:32 +0000 (+0200) Subject: When the offset is near the start we first search a bit further in the stream. X-Git-Tag: 7.0.8-14~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7842240ebb099dfe068af7bd6543a94d273e1c3c;p=imagemagick When the offset is near the start we first search a bit further in the stream. --- 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)); }