From 67ea75f92e22d55937720ca962afb79cde3487d7 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 3 Jul 2017 19:36:27 -0400 Subject: [PATCH] ... --- coders/mat.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/coders/mat.c b/coders/mat.c index c9371d888..fc19bc5c6 100644 --- a/coders/mat.c +++ b/coders/mat.c @@ -99,7 +99,7 @@ typedef struct unsigned short Version; char EndianIndicator[2]; unsigned long DataType; - unsigned long ObjectSize; + unsigned int ObjectSize; unsigned long unknown1; unsigned long unknown2; @@ -472,7 +472,7 @@ static void RelinquishZIPMemory(voidpf context,voidpf memory) #if defined(MAGICKCORE_ZLIB_DELEGATE) /** This procedure decompreses an image block for a new MATLAB format. */ -static Image *DecompressBlock(Image *orig, MagickOffsetType Size, ImageInfo *clone_info, ExceptionInfo *exception) +static Image *DecompressBlock(Image *orig, unsigned int *Size, ImageInfo *clone_info, ExceptionInfo *exception) { Image *image2; @@ -485,6 +485,7 @@ int file; int status; int zip_status; +ssize_t TotalSize = 0; if(clone_info==NULL) return NULL; if(clone_info->file) /* Close file opened from previous transaction. */ @@ -494,7 +495,7 @@ int zip_status; (void) remove_utf8(clone_info->filename); } - CacheBlock = AcquireQuantumMemory((size_t)((Size<16384)?Size:16384),sizeof(unsigned char *)); + CacheBlock = AcquireQuantumMemory((size_t)((*Size<16384)?*Size:16384),sizeof(unsigned char *)); if(CacheBlock==NULL) return NULL; DecompressBlock = AcquireQuantumMemory((size_t)(4096),sizeof(unsigned char *)); if(DecompressBlock==NULL) @@ -533,9 +534,9 @@ int zip_status; zip_info.avail_in = 0; zip_info.total_out = 0; - while(Size>0 && !EOFBlob(orig)) + while(*Size>0 && !EOFBlob(orig)) { - magick_size = ReadBlob(orig, (Size<16384)?Size:16384, (unsigned char *) CacheBlock); + magick_size = ReadBlob(orig, (*Size<16384)?*Size:16384, (unsigned char *) CacheBlock); zip_info.next_in = (Bytef *) CacheBlock; zip_info.avail_in = (uInt) magick_size; @@ -548,13 +549,14 @@ int zip_status; break; extent=fwrite(DecompressBlock, 4096-zip_info.avail_out, 1, mat_file); (void) extent; + TotalSize += 4096-zip_info.avail_out; if(zip_status == Z_STREAM_END) goto DblBreak; } if ((zip_status != Z_OK) && (zip_status != Z_STREAM_END)) break; - Size -= magick_size; + *Size -= magick_size; } DblBreak: @@ -562,6 +564,7 @@ DblBreak: (void)fclose(mat_file); RelinquishMagickMemory(CacheBlock); RelinquishMagickMemory(DecompressBlock); + *Size = TotalSize; if((clone_info->file=fopen(clone_info->filename,"rb"))==NULL) goto UnlinkFile; if( (image2 = AcquireImage(clone_info,exception))==NULL ) goto EraseFile; @@ -948,7 +951,7 @@ MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader"); #if defined(MAGICKCORE_ZLIB_DELEGATE) if(MATLAB_HDR.DataType == miCOMPRESSED) { - image2 = DecompressBlock(image,MATLAB_HDR.ObjectSize,clone_info,exception); + image2 = DecompressBlock(image,&MATLAB_HDR.ObjectSize,clone_info,exception); if(image2==NULL) continue; MATLAB_HDR.DataType = ReadBlobXXXLong(image2); /* replace compressed object type. */ } -- 2.40.0