]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 14 Aug 2014 11:37:55 +0000 (11:37 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 14 Aug 2014 11:37:55 +0000 (11:37 +0000)
MagickCore/profile.c

index 52c22d3970d8bcc24ca99437b7baaaaf6989cf7b..f2b521a2697cc718be49c98ea6711a42a7f51d5e 100644 (file)
@@ -1130,10 +1130,9 @@ static inline const unsigned char *ReadResourceShort(const unsigned char *p,
 static void WriteTo8BimProfile(Image *image,const char *name,
   const StringInfo *profile)
 {
-
   const unsigned char
     *datum,
-    *s;
+    *q;
 
   register const unsigned char
     *p;
@@ -1159,13 +1158,15 @@ static void WriteTo8BimProfile(Image *image,const char *name,
 
   if (LocaleCompare(name,"icc") == 0)
     profile_id=0x040f;
-  else if (LocaleCompare(name,"iptc") == 0)
-    profile_id=0x0404;
-  else if (LocaleCompare(name,"xmp") == 0)
-    profile_id=0x0424;
   else
-    return;
-  profile_8bim=(StringInfo *)GetValueFromSplayTree((SplayTreeInfo *)
+    if (LocaleCompare(name,"iptc") == 0)
+      profile_id=0x0404;
+    else
+      if (LocaleCompare(name,"xmp") == 0)
+        profile_id=0x0424;
+      else
+        return;
+  profile_8bim=(StringInfo *) GetValueFromSplayTree((SplayTreeInfo *)
     image->profiles,"8bim");
   if (profile_8bim == (StringInfo *) NULL)
     return;
@@ -1173,7 +1174,7 @@ static void WriteTo8BimProfile(Image *image,const char *name,
   length=GetStringInfoLength(profile_8bim);
   for (p=datum; p < (datum+length-16); )
   {
-    s=p;
+    q=p;
     if (LocaleNCompare((char *) p,"8BIM",4) != 0)
       break;
     p+=4;
@@ -1186,51 +1187,51 @@ static void WriteTo8BimProfile(Image *image,const char *name,
       break;
     p=ReadResourceLong(p,&value);
     count=(ssize_t) value;
-    if ((p > (datum+length-count)) || (count > (ssize_t) length))
-      break;
     if ((count & 0x01) != 0)
       count++;
-    if (id == profile_id)
+    if ((p > (datum+length-count)) || (count > (ssize_t) length))
+      break;
+    if (id != profile_id)
+      p+=count;
+    else
       {
         size_t
-          offset,
-          rest;
+          extent,
+          offset;
 
         ssize_t
-          new_count;
+          extract_count;
 
         StringInfo
-          *new_profile;
+          *extract_profile;
 
-        new_count=0;
-        rest=(datum+length)-(p+count);
+        extract_count=0;
+        extent=(datum+length)-(p+count);
         if (profile == (StringInfo *) NULL)
           {
-            offset=(s-datum);
-            new_profile=AcquireStringInfo(offset+rest);
-            (void) CopyMagickMemory(new_profile->datum,datum,offset);
+            offset=(q-datum);
+            extract_profile=AcquireStringInfo(offset+extent);
+            (void) CopyMagickMemory(extract_profile->datum,datum,offset);
           }
         else
           {
             offset=(p-datum);
-            new_count=profile->length;
-            if ((new_count & 0x01) != 0)
-              new_count++;
-            new_profile=AcquireStringInfo(offset+new_count+rest);
-            (void) CopyMagickMemory(new_profile->datum,datum,offset-4);
-            WriteResourceLong(new_profile->datum+offset-4,profile->length);
-            (void) CopyMagickMemory(new_profile->datum+offset,profile->datum,
-              profile->length);
+            extract_count=profile->length;
+            if ((extract_count & 0x01) != 0)
+              extract_count++;
+            extract_profile=AcquireStringInfo(offset+extract_count+extent);
+            (void) CopyMagickMemory(extract_profile->datum,datum,offset-4);
+            WriteResourceLong(extract_profile->datum+offset-4,profile->length);
+            (void) CopyMagickMemory(extract_profile->datum+offset,
+              profile->datum,profile->length);
           }
-        (void) CopyMagickMemory(new_profile->datum+offset+new_count,p+count,
-          rest);
+        (void) CopyMagickMemory(extract_profile->datum+offset+extract_count,
+          p+count,extent);
         (void) AddValueToSplayTree((SplayTreeInfo *) image->profiles,
-          ConstantString("8bim"),CloneStringInfo(new_profile));
-        new_profile=DestroyStringInfo(new_profile);
+          ConstantString("8bim"),CloneStringInfo(extract_profile));
+        extract_profile=DestroyStringInfo(extract_profile);
         break;
       }
-    else
-      p+=count;
   }
 }