]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Tue, 14 Aug 2012 12:55:55 +0000 (12:55 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Tue, 14 Aug 2012 12:55:55 +0000 (12:55 +0000)
coders/jnx.c

index 44486c64b1b93129e1d86e621f849d327b9942fd..439cb001a98740834c1b29807ed3a1b14d1d3c5e 100644 (file)
@@ -203,12 +203,12 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     jnx_level_info[i].scale=ReadBlobLSBLong(image);
     if (jnx_info.version > 3)
       {
-        unsigned short
-          c;
-
         register ssize_t
           j;
 
+        unsigned short
+          c;
+
         (void) ReadBlobLSBLong(image);
         j=0;
         while ((c=ReadBlobLSBShort(image)) != 0)
@@ -243,6 +243,9 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       int
         tile_offset;
 
+      MagickOffsetType
+        restore_offset;
+
       PointInfo
         northeast,
         southwest;
@@ -264,7 +267,10 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       (void) ReadBlobLSBShort(image); /* height */
       tile_length=ReadBlobLSBLong(image);
       tile_offset=(int) ReadBlobLSBLong(image);
-      offset=TellBlob(image);
+      restore_offset=TellBlob(image);
+      offset=SeekBlob(image,(MagickOffsetType) tile_offset,SEEK_SET);
+      if (offset != (MagickOffsetType) tile_offset)
+        continue;
       /*
         Read a tile.
       */
@@ -275,7 +281,6 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception)
             images=DestroyImageList(images);
           ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
         }
-      (void) SeekBlob(image,tile_offset,SEEK_SET);
       blob[0]=0xFF;
       blob[1]=0xD8;
       count=ReadBlob(image,tile_length,blob+2);
@@ -291,10 +296,10 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       tile_image=BlobToImage(read_info,blob,tile_length+2,exception);
       read_info=DestroyImageInfo(read_info);
       blob=(unsigned char *) RelinquishMagickMemory(blob);
-      (void) SeekBlob(image,offset,SEEK_SET);
+      offset=SeekBlob(image,restore_offset,SEEK_SET);
       if (tile_image == (Image *) NULL)
         continue;
-       (void) CopyMagickString(tile_image->magick,image->magick,MaxTextExtent);
+      (void) CopyMagickString(tile_image->magick,image->magick,MaxTextExtent);
       (void) FormatImageProperty(tile_image,"jnx:northeast","%.20g,%.20g",
         northeast.x,northeast.y);
       (void) FormatImageProperty(tile_image,"jnx:southwest","%.20g,%.20g",