From df87801109a073f91e0b3a1c3a6ba081ee0b5fd1 Mon Sep 17 00:00:00 2001 From: cristy Date: Sun, 12 Jan 2014 23:39:40 +0000 Subject: [PATCH] --- coders/jpeg.c | 71 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/coders/jpeg.c b/coders/jpeg.c index 88f67ffd8..fdb04e22b 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -414,11 +414,14 @@ static boolean ReadComment(j_decompress_ptr jpeg_info) length+=GetCharacter(jpeg_info); length-=2; if (length <= 0) - return(MagickTrue); + return(TRUE); comment=BlobToStringInfo((const void *) NULL,length); if (comment == (StringInfo *) NULL) - ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", - image->filename); + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); + return(FALSE); + } /* Read comment. */ @@ -431,7 +434,7 @@ static boolean ReadComment(j_decompress_ptr jpeg_info) p=GetStringInfoDatum(comment); (void) SetImageProperty(image,"comment",(const char *) p,exception); comment=DestroyStringInfo(comment); - return(MagickTrue); + return(TRUE); } static boolean ReadICCProfile(j_decompress_ptr jpeg_info) @@ -474,7 +477,7 @@ static boolean ReadICCProfile(j_decompress_ptr jpeg_info) { while (length-- > 0) (void) GetCharacter(jpeg_info); - return(MagickTrue); + return(TRUE); } for (i=0; i < 12; i++) magick[i]=(char) GetCharacter(jpeg_info); @@ -485,7 +488,7 @@ static boolean ReadICCProfile(j_decompress_ptr jpeg_info) */ for (i=0; i < (ssize_t) (length-12); i++) (void) GetCharacter(jpeg_info); - return(MagickTrue); + return(TRUE); } (void) GetCharacter(jpeg_info); /* id */ (void) GetCharacter(jpeg_info); /* markers */ @@ -495,8 +498,11 @@ static boolean ReadICCProfile(j_decompress_ptr jpeg_info) image=error_manager->image; profile=BlobToStringInfo((const void *) NULL,length); if (profile == (StringInfo *) NULL) - ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", - image->filename); + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); + return(FALSE); + } error_manager->profile=profile; p=GetStringInfoDatum(profile); for (i=(ssize_t) GetStringInfoLength(profile)-1; i >= 0; i--) @@ -519,7 +525,7 @@ static boolean ReadICCProfile(j_decompress_ptr jpeg_info) if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Profile: ICC, %.20g bytes",(double) length); - return(MagickTrue); + return(TRUE); } static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info) @@ -562,7 +568,7 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info) { while (length-- > 0) (void) GetCharacter(jpeg_info); - return(MagickTrue); + return(TRUE); } /* Validate that this was written as a Photoshop resource format slug. @@ -571,7 +577,7 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info) magick[i]=(char) GetCharacter(jpeg_info); magick[10]='\0'; if (length <= 10) - return(MagickTrue); + return(TRUE); length-=10; if (LocaleCompare(magick,"Photoshop ") != 0) { @@ -580,7 +586,7 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info) */ for (i=0; i < (ssize_t) length; i++) (void) GetCharacter(jpeg_info); - return(MagickTrue); + return(TRUE); } /* Remove the version number. @@ -597,8 +603,11 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info) image=error_manager->image; profile=BlobToStringInfo((const void *) NULL,length); if (profile == (StringInfo *) NULL) - ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", - image->filename); + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); + return(FALSE); + } error_manager->profile=profile; p=GetStringInfoDatum(profile); for (i=0; i < (ssize_t) GetStringInfoLength(profile); i++) @@ -621,7 +630,7 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info) if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Profile: iptc, %.20g bytes",(double) length); - return(MagickTrue); + return(TRUE); } static boolean ReadProfile(j_decompress_ptr jpeg_info) @@ -665,7 +674,7 @@ static boolean ReadProfile(j_decompress_ptr jpeg_info) length=(size_t) ((size_t) GetCharacter(jpeg_info) << 8); length+=(size_t) GetCharacter(jpeg_info); if (length <= 2) - return(MagickTrue); + return(TRUE); length-=2; marker=jpeg_info->unread_marker-JPEG_APP0; (void) FormatLocaleString(name,MaxTextExtent,"APP%d",marker); @@ -674,8 +683,11 @@ static boolean ReadProfile(j_decompress_ptr jpeg_info) image=error_manager->image; profile=BlobToStringInfo((const void *) NULL,length); if (profile == (StringInfo *) NULL) - ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", - image->filename); + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); + return(FALSE); + } error_manager->profile=profile; p=GetStringInfoDatum(profile); for (i=0; i < (ssize_t) GetStringInfoLength(profile); i++) @@ -725,12 +737,15 @@ static boolean ReadProfile(j_decompress_ptr jpeg_info) status=SetImageProfile(image,name,profile,exception); profile=DestroyStringInfo(profile); if (status == MagickFalse) - ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", - image->filename); + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); + return(FALSE); + } if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "Profile: %s, %.20g bytes",name,(double) length); - return(MagickTrue); + return(TRUE); } static void SkipInputData(j_decompress_ptr cinfo,long number_bytes) @@ -1078,7 +1093,7 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, for (i=1; i < 16; i++) if ((i != 2) && (i != 13) && (i != 14)) jpeg_set_marker_processor(&jpeg_info,(int) (JPEG_APP0+i),ReadProfile); - i=(ssize_t) jpeg_read_header(&jpeg_info,MagickTrue); + i=(ssize_t) jpeg_read_header(&jpeg_info,TRUE); if ((image_info->colorspace == YCbCrColorspace) || (image_info->colorspace == Rec601YCbCrColorspace) || (image_info->colorspace == Rec709YCbCrColorspace)) @@ -1160,12 +1175,13 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, /* Let the JPEG library quantize the image. */ - jpeg_info.quantize_colors=MagickTrue; + jpeg_info.quantize_colors=TRUE; jpeg_info.desired_number_of_colors=(int) StringToUnsignedLong(option); } option=GetImageOption(image_info,"jpeg:block-smoothing"); if (option != (const char *) NULL) - jpeg_info.do_block_smoothing=IsStringTrue(option); + jpeg_info.do_block_smoothing=IsStringTrue(option) != MagickFalse ? TRUE : + FALSE; jpeg_info.dct_method=JDCT_FLOAT; option=GetImageOption(image_info,"jpeg:dct-method"); if (option != (const char *) NULL) @@ -1199,7 +1215,8 @@ static Image *ReadJPEGImage(const ImageInfo *image_info, } option=GetImageOption(image_info,"jpeg:fancy-upsampling"); if (option != (const char *) NULL) - jpeg_info.do_fancy_upsampling=IsStringTrue(option); + jpeg_info.do_fancy_upsampling=IsStringTrue(option) != MagickFalse ? TRUE : + FALSE; (void) jpeg_start_decompress(&jpeg_info); image->columns=jpeg_info.output_width; image->rows=jpeg_info.output_height; @@ -2171,7 +2188,7 @@ static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info, /* Set image resolution. */ - jpeg_info.write_JFIF_header=MagickTrue; + jpeg_info.write_JFIF_header=TRUE; jpeg_info.X_density=(UINT16) floor(image->resolution.x+0.5); jpeg_info.Y_density=(UINT16) floor(image->resolution.y+0.5); /* @@ -2216,7 +2233,7 @@ static MagickBooleanType WriteJPEGImage(const ImageInfo *image_info, } option=GetImageOption(image_info,"jpeg:optimize-coding"); if (option != (const char *) NULL) - jpeg_info.optimize_coding=IsStringTrue(option); + jpeg_info.optimize_coding=IsStringTrue(option) != MagickFalse ? TRUE : FALSE; else { MagickSizeType -- 2.40.0