]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/magic.c
Update web pages
[imagemagick] / MagickCore / magic.c
index 3ca21e166728852750252c89ec1e6d05ff64290d..5d446ee55427eb9bcbae7e774002dff933c26256 100644 (file)
@@ -251,7 +251,11 @@ static int CompareMagickInfoSize(const void *a,const void *b)
 
   ma=(MagicInfo *) a;
   mb=(MagicInfo *) b;
-  return((int) ((mb->offset+mb->length)-(ma->offset+ma->length)));
+
+  if (ma->offset != mb->offset)
+    return((int) (ma->offset-mb->offset));
+
+  return((int) (mb->length-ma->length));
 }
 
 static LinkedListInfo *AcquireMagicCache(const char *filename,
@@ -318,7 +322,7 @@ static LinkedListInfo *AcquireMagicCache(const char *filename,
     magic_info->magic=(unsigned char *) p->magic;
     magic_info->length=p->length;
     magic_info->exempt=MagickTrue;
-    magic_info->signature=MagickSignature;
+    magic_info->signature=MagickCoreSignature;
     status&=InsertValueInSortedLinkedList(magic_cache,CompareMagickInfoSize,
       NULL,magic_info);
     if (status == MagickFalse)
@@ -420,20 +424,28 @@ MagickExport size_t GetMagicPatternExtent(ExceptionInfo *exception)
   register const MagicInfo
     *p;
 
+  size_t
+    magickSize,
+    max;
+
   static size_t
-    size = 0;
+    size=0;
 
   assert(exception != (ExceptionInfo *) NULL);
   if ((size != 0) || (IsMagicCacheInstantiated(exception) == MagickFalse))
     return(size);
-  /*
-    The list is sorted so we can use the size of the first value.
-  */
   LockSemaphoreInfo(magic_semaphore);
   ResetLinkedListIterator(magic_cache);
+  max=0;
   p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
-  if (p != (const MagicInfo *) NULL)
-    size=(size_t) (p->offset+p->length);
+  while (p != (const MagicInfo *) NULL)
+  {
+    magickSize=(size_t) (p->offset+p->length);
+    if (magickSize > max)
+      max=magickSize;
+    p=(const MagicInfo *) GetNextValueInLinkedList(magic_cache);
+  }
+  size=max;
   UnlockSemaphoreInfo(magic_semaphore);
   return(size);
 }
@@ -652,7 +664,7 @@ MagickExport const char *GetMagicName(const MagicInfo *magic_info)
 {
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   assert(magic_info != (MagicInfo *) NULL);
-  assert(magic_info->signature == MagickSignature);
+  assert(magic_info->signature == MagickCoreSignature);
   return(magic_info->name);
 }
 \f
@@ -919,7 +931,7 @@ static MagickBooleanType LoadMagicCache(LinkedListInfo *magic_cache,
         (void) ResetMagickMemory(magic_info,0,sizeof(*magic_info));
         magic_info->path=ConstantString(filename);
         magic_info->exempt=MagickFalse;
-        magic_info->signature=MagickSignature;
+        magic_info->signature=MagickCoreSignature;
         continue;
       }
     if (magic_info == (MagicInfo *) NULL)