From 6892ab82aa430ec9cf531f187a4ad51bbd63c613 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 17 Apr 2021 14:44:56 -0400 Subject: [PATCH 01/15] ... --- configure | 36 ++++++++++++++++++------------------ m4/version.m4 | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/configure b/configure index 68a75383f..cde052893 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ImageMagick 7.0.11-8. +# Generated by GNU Autoconf 2.69 for ImageMagick 7.0.11-9. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ImageMagick' PACKAGE_TARNAME='ImageMagick' -PACKAGE_VERSION='7.0.11-8' -PACKAGE_STRING='ImageMagick 7.0.11-8' +PACKAGE_VERSION='7.0.11-9' +PACKAGE_STRING='ImageMagick 7.0.11-9' PACKAGE_BUGREPORT='https://github.com/ImageMagick/ImageMagick/issues' PACKAGE_URL='https://imagemagick.org' @@ -1845,7 +1845,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ImageMagick 7.0.11-8 to adapt to many kinds of systems. +\`configure' configures ImageMagick 7.0.11-9 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1920,7 +1920,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ImageMagick 7.0.11-8:";; + short | recursive ) echo "Configuration of ImageMagick 7.0.11-9:";; esac cat <<\_ACEOF @@ -2216,7 +2216,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ImageMagick configure 7.0.11-8 +ImageMagick configure 7.0.11-9 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -3267,7 +3267,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ImageMagick $as_me 7.0.11-8, which was +It was created by ImageMagick $as_me 7.0.11-9, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -4255,7 +4255,7 @@ fi # Define the identity of the package. PACKAGE='ImageMagick' - VERSION='7.0.11-8' + VERSION='7.0.11-9' # Some tools Automake needs. @@ -4548,11 +4548,11 @@ MAGICK_MINOR_VERSION=0 MAGICK_MICRO_VERSION=11 -MAGICK_PATCHLEVEL_VERSION=8 +MAGICK_PATCHLEVEL_VERSION=9 -MAGICK_VERSION=7.0.11-8 +MAGICK_VERSION=7.0.11-9 -MAGICK_GIT_REVISION=18619:8ea469ae9:20210412 +MAGICK_GIT_REVISION=18639:0b8f536a9:20210417 # Substitute library versioning @@ -4574,15 +4574,15 @@ MAGICKPP_LIBRARY_VERSION_INFO=$MAGICKPP_LIBRARY_CURRENT:$MAGICKPP_LIBRARY_REVISI PACKAGE_BASE_VERSION=7.0.11 -PACKAGE_PATCHLEVEL_VERSION=8 +PACKAGE_PATCHLEVEL_VERSION=9 -PACKAGE_VERSION_ADDENDUM=-8 +PACKAGE_VERSION_ADDENDUM=-9 PACKAGE_LIB_VERSION=0x70B -PACKAGE_LIB_VERSION_NUMBER=7,0,11,8 +PACKAGE_LIB_VERSION_NUMBER=7,0,11,9 -PACKAGE_RELEASE_DATE=2021-04-11 +PACKAGE_RELEASE_DATE=2021-04-17 # Ensure that make can run correctly @@ -30929,7 +30929,7 @@ $as_echo_n "checking if jpeg-xl package is complete... " >&6; } $as_echo "no -- some components failed test" >&6; } have_jxl='no (failed tests)' else - JXL_LIBS='-ljxl' + JXL_LIBS='-ljxl -ljxl_threads' LIBS="$JXL_LIBS $LIBS" $as_echo "#define JXL_DELEGATE 1" >>confdefs.h @@ -36944,7 +36944,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ImageMagick $as_me 7.0.11-8, which was +This file was extended by ImageMagick $as_me 7.0.11-9, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -37011,7 +37011,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ImageMagick config.status 7.0.11-8 +ImageMagick config.status 7.0.11-9 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/m4/version.m4 b/m4/version.m4 index 1a165ed24..63ea1f334 100644 --- a/m4/version.m4 +++ b/m4/version.m4 @@ -27,7 +27,7 @@ m4_define([magick_name], [ImageMagick]) m4_define([magick_major_version], [7]) m4_define([magick_minor_version], [0]) m4_define([magick_micro_version], [11]) -m4_define([magick_patchlevel_version], [8]) +m4_define([magick_patchlevel_version], [9]) m4_define([magick_bugreport], [https://github.com/ImageMagick/ImageMagick/issues]) m4_define([magick_url], [https://imagemagick.org]) From f4b9193db473a06f6e259bbf5e673f52ea39f8a7 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 17 Apr 2021 14:48:48 -0400 Subject: [PATCH 02/15] ... --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index cde052893..e6cd1c692 100755 --- a/configure +++ b/configure @@ -4552,7 +4552,7 @@ MAGICK_PATCHLEVEL_VERSION=9 MAGICK_VERSION=7.0.11-9 -MAGICK_GIT_REVISION=18639:0b8f536a9:20210417 +MAGICK_GIT_REVISION=18640:6892ab82a:20210417 # Substitute library versioning From 4594c6d17e5a5e394808e11c2c69b22edeb23c54 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sat, 17 Apr 2021 21:03:31 +0200 Subject: [PATCH 03/15] Corrected ChangeLog. --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 409b379d9..7c8c6d7c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ * added support for pdf:author, pdf:producer and pdf:title when writing a PDF file. +2021-04-10 7.0.11-7 + * Release ImageMagick version 7.0.11-7 GIT revision 18617:2a0925961:20210411 + 2021-04-09 7.0.11-7 * constrain sub-image list. * -layers optimize no longer produces broken output (reference From b2f2a1bdec22fbeac79a99abe2189b9fe4ac396a Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 17 Apr 2021 20:46:26 -0400 Subject: [PATCH 04/15] ... --- MagickCore/draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 23fde9228..8e7696a88 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -91,7 +91,7 @@ Define declarations. */ #define BezierQuantum 200 -#define PrimitiveExtentPad 2053.0 +#define PrimitiveExtentPad 4096.0 #define MaxBezierCoordinates 67108864 #define ThrowPointExpectedException(token,exception) \ { \ From 2211bca59402860adeb56c49d286057d08f50ec1 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 17 Apr 2021 20:57:32 -0400 Subject: [PATCH 05/15] ... --- MagickCore/draw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 8e7696a88..136fb3931 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -2287,7 +2287,10 @@ static MagickBooleanType CheckPrimitiveExtent(MVGInfo *mvg_info, *mvg_info->extent=(size_t) extent; for (i=mvg_info->offset+1; i <= (ssize_t) extent; i++) + { (*mvg_info->primitive_info)[i].primitive=UndefinedPrimitive; + (*mvg_info->primitive_info)[i].text=(char *) NULL; + } return(MagickTrue); } } From 31f186de27faf7ea149055a5f48bbe8d796b518c Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 17 Apr 2021 20:58:33 -0400 Subject: [PATCH 06/15] ... --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7c8c6d7c7..a66824c31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-04-17 7.0.11-9 + * Release ImageMagick version 7.0.11-9 GIT revision 18... + +2021-04-17 7.0.11-8 + * eliminate uninitialized value + 2021-04-17 7.0.11-8 * Release ImageMagick version 7.0.11-8 GIT revision 18636:53a252607:20210417 From 816e0069d9bf63c17052172781ba21a74036b589 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 18 Apr 2021 21:01:01 +0200 Subject: [PATCH 07/15] Corrected typo. --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a66824c31..a49f89eaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,7 +29,7 @@ * Release ImageMagick version 7.0.11-5 GIT revision 18569:b934dca6b:20210328 2021-03-25 7.0.11-5 Dirk Lemstra - * OpenCL will be disable by default, use the environment variable + * OpenCL will be disabled by default, use the environment variable MAGICK_OCL_DEVICE to turn it on or select the device to use. 2021-03-24 7.0.11-5 From 3b0644ed9f6d43d8153f8122fe197cce80850b79 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 18 Apr 2021 16:49:47 -0400 Subject: [PATCH 08/15] ... --- coders/jpeg.c | 53 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/coders/jpeg.c b/coders/jpeg.c index db385358b..f536b26ac 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -1036,7 +1036,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, *option; ErrorManager - error_manager; + *error_manager; Image *image; @@ -1105,7 +1105,10 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, /* Initialize JPEG parameters. */ - (void) memset(&error_manager,0,sizeof(error_manager)); + error_manager=(ErrorManager *) AcquireMagickMemory(sizeof(*error_manager)); + if (error_manager == (ErrorManager *) NULL) + ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + (void) memset(error_manager,0,sizeof(*error_manager)); (void) memset(jpeg_info,0,sizeof(*jpeg_info)); (void) memset(&jpeg_error,0,sizeof(jpeg_error)); (void) memset(&jpeg_progress,0,sizeof(jpeg_progress)); @@ -1113,17 +1116,18 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, jpeg_info->err->emit_message=(void (*)(j_common_ptr,int)) JPEGWarningHandler; jpeg_info->err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler; memory_info=(MemoryInfo *) NULL; - error_manager.exception=exception; - error_manager.image=image; - if (setjmp(error_manager.error_recovery) != 0) + error_manager->exception=exception; + error_manager->image=image; + if (setjmp(error_manager->error_recovery) != 0) { JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); (void) CloseBlob(image); if (exception->severity < ErrorException) return(GetFirstImageInList(image)); return(DestroyImage(image)); } - jpeg_info->client_data=(void *) &error_manager; + jpeg_info->client_data=(void *) error_manager; jpeg_create_decompress(jpeg_info); if (GetMaxMemoryRequest() != ~0UL) jpeg_info->mem->max_memory_to_use=(long) GetMaxMemoryRequest(); @@ -1303,6 +1307,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (AcquireImageColormap(image,StringToUnsignedLong(option),exception) == MagickFalse) { JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } if ((jpeg_info->output_components == 1) && (jpeg_info->quantize_colors == 0)) @@ -1314,6 +1319,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (AcquireImageColormap(image,colors,exception) == MagickFalse) { JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } } @@ -1339,14 +1345,16 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (jpeg_info->arith_code == TRUE) (void) SetImageProperty(image,"jpeg:coding","arithmetic",exception); #endif - if (JPEGSetImageProfiles(&error_manager) == MagickFalse) + if (JPEGSetImageProfiles(error_manager) == MagickFalse) { JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); return(DestroyImageList(image)); } if (image_info->ping != MagickFalse) { JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); (void) CloseBlob(image); return(GetFirstImageInList(image)); } @@ -1354,6 +1362,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (status == MagickFalse) { JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); return(DestroyImageList(image)); } (void) jpeg_start_decompress(jpeg_info); @@ -1361,6 +1370,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, (jpeg_info->output_components != 3) && (jpeg_info->output_components != 4)) { JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); ThrowReaderException(CorruptImageError,"ImageTypeNotSupported"); } memory_info=AcquireVirtualMemory((size_t) image->columns, @@ -1368,6 +1378,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (memory_info == (MemoryInfo *) NULL) { JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info); @@ -1376,11 +1387,12 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, /* Convert JPEG pixels to pixel packets. */ - if (setjmp(error_manager.error_recovery) != 0) + if (setjmp(error_manager->error_recovery) != 0) { if (memory_info != (MemoryInfo *) NULL) memory_info=RelinquishVirtualMemory(memory_info); JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); (void) CloseBlob(image); number_pixels=(MagickSizeType) image->columns*image->rows; if (number_pixels != 0) @@ -1531,14 +1543,15 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, } if (status != MagickFalse) { - error_manager.finished=MagickTrue; - if (setjmp(error_manager.error_recovery) == 0) + error_manager->finished=MagickTrue; + if (setjmp(error_manager->error_recovery) == 0) (void) jpeg_finish_decompress(jpeg_info); } /* Free jpeg resources. */ JPEGDestroyDecompress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); memory_info=RelinquishVirtualMemory(memory_info); (void) CloseBlob(image); return(GetFirstImageInList(image)); @@ -2194,7 +2207,7 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, *value; ErrorManager - error_manager; + *error_manager; Image *volatile volatile_image; @@ -2250,7 +2263,10 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, /* Initialize JPEG parameters. */ - (void) memset(&error_manager,0,sizeof(error_manager)); + error_manager=(ErrorManager *) AcquireMagickMemory(sizeof(*error_manager)); + if (error_manager == (ErrorManager *) NULL) + ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); + (void) memset(error_manager,0,sizeof(*error_manager)); (void) memset(jpeg_info,0,sizeof(*jpeg_info)); (void) memset(&jpeg_error,0,sizeof(jpeg_error)); volatile_image=image; @@ -2258,16 +2274,17 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, jpeg_info->err=jpeg_std_error(&jpeg_error); jpeg_info->err->emit_message=(void (*)(j_common_ptr,int)) JPEGWarningHandler; jpeg_info->err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler; - error_manager.exception=exception; - error_manager.image=volatile_image; + error_manager->exception=exception; + error_manager->image=volatile_image; memory_info=(MemoryInfo *) NULL; - if (setjmp(error_manager.error_recovery) != 0) + if (setjmp(error_manager->error_recovery) != 0) { jpeg_destroy_compress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); (void) CloseBlob(volatile_image); return(MagickFalse); } - jpeg_info->client_data=(void *) &error_manager; + jpeg_info->client_data=(void *) error_manager; jpeg_create_compress(jpeg_info); JPEGDestinationManager(jpeg_info,image); if ((image->columns != (unsigned int) image->columns) || @@ -2789,9 +2806,10 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, if (memory_info == (MemoryInfo *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info); - if (setjmp(error_manager.error_recovery) != 0) + if (setjmp(error_manager->error_recovery) != 0) { jpeg_destroy_compress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); if (memory_info != (MemoryInfo *) NULL) memory_info=RelinquishVirtualMemory(memory_info); (void) CloseBlob(image); @@ -2986,6 +3004,7 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, Relinquish resources. */ jpeg_destroy_compress(jpeg_info); + error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); memory_info=RelinquishVirtualMemory(memory_info); (void) CloseBlob(image); return(MagickTrue); From fea4e7aa391c625765febcb508dc17f971934386 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 18 Apr 2021 17:07:07 -0400 Subject: [PATCH 09/15] cosmetic --- coders/jpeg.c | 253 +++++++++++++++++++++++++------------------------- 1 file changed, 128 insertions(+), 125 deletions(-) diff --git a/coders/jpeg.c b/coders/jpeg.c index f536b26ac..46ac4999c 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -125,7 +125,7 @@ typedef struct _DestinationManager *buffer; } DestinationManager; -typedef struct _ErrorManager +typedef struct _JPEGClientInfo { jmp_buf error_recovery; @@ -141,7 +141,7 @@ typedef struct _ErrorManager ExceptionInfo *exception; -} ErrorManager; +} JPEGClientInfo; typedef struct _SourceManager { @@ -254,19 +254,19 @@ static MagickBooleanType IsJPEG(const unsigned char *magick,const size_t length) % */ -static boolean FillInputBuffer(j_decompress_ptr cinfo) +static boolean FillInputBuffer(j_decompress_ptr compress_info) { SourceManager *source; - source=(SourceManager *) cinfo->src; + source=(SourceManager *) compress_info->src; source->manager.bytes_in_buffer=(size_t) ReadBlob(source->image, MagickMinBufferExtent,source->buffer); if (source->manager.bytes_in_buffer == 0) { if (source->start_of_blob != FALSE) - ERREXIT(cinfo,JERR_INPUT_EMPTY); - WARNMS(cinfo,JWRN_JPEG_EOF); + ERREXIT(compress_info,JERR_INPUT_EMPTY); + WARNMS(compress_info,JWRN_JPEG_EOF); source->buffer[0]=(JOCTET) 0xff; source->buffer[1]=(JOCTET) JPEG_EOI; source->manager.bytes_in_buffer=2; @@ -288,12 +288,12 @@ static int GetCharacter(j_decompress_ptr jpeg_info) return((int) GETJOCTET(*jpeg_info->src->next_input_byte++)); } -static void InitializeSource(j_decompress_ptr cinfo) +static void InitializeSource(j_decompress_ptr compress_info) { SourceManager *source; - source=(SourceManager *) cinfo->src; + source=(SourceManager *) compress_info->src; source->start_of_blob=TRUE; } @@ -322,53 +322,53 @@ static void JPEGErrorHandler(j_common_ptr jpeg_info) char message[JMSG_LENGTH_MAX]; - ErrorManager - *error_manager; - ExceptionInfo *exception; Image *image; + JPEGClientInfo + *client_info; + *message='\0'; - error_manager=(ErrorManager *) jpeg_info->client_data; - image=error_manager->image; - exception=error_manager->exception; + client_info=(JPEGClientInfo *) jpeg_info->client_data; + image=client_info->image; + exception=client_info->exception; (jpeg_info->err->format_message)(jpeg_info,message); if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "[%s] JPEG Trace: \"%s\"",image->filename,message); - if (error_manager->finished != MagickFalse) + if (client_info->finished != MagickFalse) (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageWarning, (char *) message,"`%s'",image->filename); else (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError, (char *) message,"`%s'",image->filename); - longjmp(error_manager->error_recovery,1); + longjmp(client_info->error_recovery,1); } static void JPEGProgressHandler(j_common_ptr jpeg_info) { - ErrorManager - *error_manager; - ExceptionInfo *exception; Image *image; - error_manager=(ErrorManager *) jpeg_info->client_data; - image=error_manager->image; - exception=error_manager->exception; + JPEGClientInfo + *client_info; + + client_info=(JPEGClientInfo *) jpeg_info->client_data; + image=client_info->image; + exception=client_info->exception; if (jpeg_info->is_decompressor == 0) return; if (((j_decompress_ptr) jpeg_info)->input_scan_number < MaxJPEGScans) return; (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError, "too many scans","`%s'",image->filename); - longjmp(error_manager->error_recovery,1); + longjmp(client_info->error_recovery,1); } static MagickBooleanType JPEGWarningHandler(j_common_ptr jpeg_info,int level) @@ -378,19 +378,19 @@ static MagickBooleanType JPEGWarningHandler(j_common_ptr jpeg_info,int level) char message[JMSG_LENGTH_MAX]; - ErrorManager - *error_manager; - ExceptionInfo *exception; Image *image; + JPEGClientInfo + *client_info; + *message='\0'; - error_manager=(ErrorManager *) jpeg_info->client_data; - exception=error_manager->exception; - image=error_manager->image; + client_info=(JPEGClientInfo *) jpeg_info->client_data; + exception=client_info->exception; + image=client_info->image; if (level < 0) { /* @@ -418,46 +418,46 @@ static MagickBooleanType JPEGWarningHandler(j_common_ptr jpeg_info,int level) static boolean ReadProfileData(j_decompress_ptr jpeg_info,const size_t index, const size_t length) { - ErrorManager - *error_manager; - ExceptionInfo *exception; Image *image; + JPEGClientInfo + *client_info; + unsigned char *p; ssize_t i; - error_manager=(ErrorManager *) jpeg_info->client_data; - exception=error_manager->exception; - image=error_manager->image; - if (error_manager->profiles[index] == (StringInfo *) NULL) + client_info=(JPEGClientInfo *) jpeg_info->client_data; + exception=client_info->exception; + image=client_info->image; + if (client_info->profiles[index] == (StringInfo *) NULL) { - error_manager->profiles[index]=BlobToStringInfo((const void *) NULL, + client_info->profiles[index]=BlobToStringInfo((const void *) NULL, length); - if (error_manager->profiles[index] == (StringInfo *) NULL) + if (client_info->profiles[index] == (StringInfo *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'", image->filename); return(FALSE); } - p=GetStringInfoDatum(error_manager->profiles[index]); + p=GetStringInfoDatum(client_info->profiles[index]); } else { size_t current_length; - current_length=GetStringInfoLength(error_manager->profiles[index]); - SetStringInfoLength(error_manager->profiles[index],current_length+ + current_length=GetStringInfoLength(client_info->profiles[index]); + SetStringInfoLength(client_info->profiles[index],current_length+ length); - p=GetStringInfoDatum(error_manager->profiles[index])+current_length; + p=GetStringInfoDatum(client_info->profiles[index])+current_length; } for (i=0; i < (ssize_t) length; i++) { @@ -631,15 +631,15 @@ static boolean ReadProfile(j_decompress_ptr jpeg_info) static boolean ReadXmlProfile(j_decompress_ptr jpeg_info) { - ErrorManager - *error_manager; - ExceptionInfo *exception; Image *image; + JPEGClientInfo + *client_info; + MagickBooleanType status; @@ -658,10 +658,10 @@ static boolean ReadXmlProfile(j_decompress_ptr jpeg_info) length-=2; if (ReadProfileData(jpeg_info,XML_INDEX,length) == FALSE) return(FALSE); - error_manager=(ErrorManager *) jpeg_info->client_data; - exception=error_manager->exception; - image=error_manager->image; - profile=error_manager->profiles[XML_INDEX]; + client_info=(JPEGClientInfo *) jpeg_info->client_data; + exception=client_info->exception; + image=client_info->image; + profile=client_info->profiles[XML_INDEX]; p=GetStringInfoDatum(profile); length=GetStringInfoLength(profile); status=MagickTrue; @@ -695,44 +695,45 @@ static boolean ReadXmlProfile(j_decompress_ptr jpeg_info) } else status=SetImageProfile(image,"app1",profile,exception); - error_manager->profiles[XML_INDEX]=DestroyStringInfo( - error_manager->profiles[XML_INDEX]); + client_info->profiles[XML_INDEX]=DestroyStringInfo( + client_info->profiles[XML_INDEX]); return(status != MagickFalse ? TRUE : FALSE); } -static void SkipInputData(j_decompress_ptr cinfo,long number_bytes) +static void SkipInputData(j_decompress_ptr compress_info,long number_bytes) { SourceManager *source; if (number_bytes <= 0) return; - source=(SourceManager *) cinfo->src; + source=(SourceManager *) compress_info->src; while (number_bytes > (long) source->manager.bytes_in_buffer) { number_bytes-=(long) source->manager.bytes_in_buffer; - (void) FillInputBuffer(cinfo); + (void) FillInputBuffer(compress_info); } source->manager.next_input_byte+=number_bytes; source->manager.bytes_in_buffer-=number_bytes; } -static void TerminateSource(j_decompress_ptr cinfo) +static void TerminateSource(j_decompress_ptr compress_info) { - (void) cinfo; + (void) compress_info; } -static void JPEGSourceManager(j_decompress_ptr cinfo,Image *image) +static void JPEGSourceManager(j_decompress_ptr compress_info,Image *image) { SourceManager *source; - cinfo->src=(struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo,JPOOL_IMAGE,sizeof(SourceManager)); - source=(SourceManager *) cinfo->src; - source->buffer=(JOCTET *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo,JPOOL_IMAGE,MagickMinBufferExtent*sizeof(JOCTET)); - source=(SourceManager *) cinfo->src; + compress_info->src=(struct jpeg_source_mgr *) (* + compress_info->mem->alloc_small) ((j_common_ptr) compress_info,JPOOL_IMAGE, + sizeof(SourceManager)); + source=(SourceManager *) compress_info->src; + source->buffer=(JOCTET *) (*compress_info->mem->alloc_small) ((j_common_ptr) + compress_info,JPOOL_IMAGE,MagickMinBufferExtent*sizeof(JOCTET)); + source=(SourceManager *) compress_info->src; source->manager.init_source=InitializeSource; source->manager.fill_input_buffer=FillInputBuffer; source->manager.skip_input_data=SkipInputData; @@ -944,22 +945,22 @@ static void JPEGSetImageSamplingFactor(struct jpeg_decompress_struct *jpeg_info, static void JPEGDestroyDecompress(j_decompress_ptr jpeg_info) { - ErrorManager - *error_manager; + JPEGClientInfo + *client_info; size_t i; - error_manager=(ErrorManager *) jpeg_info->client_data; + client_info=(JPEGClientInfo *) jpeg_info->client_data; for (i=0; i < 16; i++) { - if (error_manager->profiles[i] != (StringInfo *) NULL) - error_manager->profiles[i]=DestroyStringInfo(error_manager->profiles[i]); + if (client_info->profiles[i] != (StringInfo *) NULL) + client_info->profiles[i]=DestroyStringInfo(client_info->profiles[i]); } jpeg_destroy_decompress(jpeg_info); } -static MagickBooleanType JPEGSetImageProfiles(ErrorManager *error_manager) +static MagickBooleanType JPEGSetImageProfiles(JPEGClientInfo *client_info) { ExceptionInfo *exception; @@ -979,12 +980,12 @@ static MagickBooleanType JPEGSetImageProfiles(ErrorManager *error_manager) StringInfo *profile; - exception=error_manager->exception; - image=error_manager->image; + exception=client_info->exception; + image=client_info->image; status=MagickTrue; for (i=0; i < 16; i++) { - profile=error_manager->profiles[i]; + profile=client_info->profiles[i]; if (profile == (StringInfo *) NULL) continue; switch (i) @@ -1018,7 +1019,7 @@ static MagickBooleanType JPEGSetImageProfiles(ErrorManager *error_manager) break; } } - error_manager->profiles[i]=DestroyStringInfo(error_manager->profiles[i]); + client_info->profiles[i]=DestroyStringInfo(client_info->profiles[i]); if (status == MagickFalse) break; } @@ -1035,12 +1036,12 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, *dct_method, *option; - ErrorManager - *error_manager; - Image *image; + JPEGClientInfo + *client_info; + JSAMPLE *volatile jpeg_pixels; @@ -1105,10 +1106,10 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, /* Initialize JPEG parameters. */ - error_manager=(ErrorManager *) AcquireMagickMemory(sizeof(*error_manager)); - if (error_manager == (ErrorManager *) NULL) + client_info=(JPEGClientInfo *) AcquireMagickMemory(sizeof(*client_info)); + if (client_info == (JPEGClientInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); - (void) memset(error_manager,0,sizeof(*error_manager)); + (void) memset(client_info,0,sizeof(*client_info)); (void) memset(jpeg_info,0,sizeof(*jpeg_info)); (void) memset(&jpeg_error,0,sizeof(jpeg_error)); (void) memset(&jpeg_progress,0,sizeof(jpeg_progress)); @@ -1116,18 +1117,18 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, jpeg_info->err->emit_message=(void (*)(j_common_ptr,int)) JPEGWarningHandler; jpeg_info->err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler; memory_info=(MemoryInfo *) NULL; - error_manager->exception=exception; - error_manager->image=image; - if (setjmp(error_manager->error_recovery) != 0) + client_info->exception=exception; + client_info->image=image; + if (setjmp(client_info->error_recovery) != 0) { JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); (void) CloseBlob(image); if (exception->severity < ErrorException) return(GetFirstImageInList(image)); return(DestroyImage(image)); } - jpeg_info->client_data=(void *) error_manager; + jpeg_info->client_data=(void *) client_info; jpeg_create_decompress(jpeg_info); if (GetMaxMemoryRequest() != ~0UL) jpeg_info->mem->max_memory_to_use=(long) GetMaxMemoryRequest(); @@ -1307,7 +1308,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (AcquireImageColormap(image,StringToUnsignedLong(option),exception) == MagickFalse) { JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } if ((jpeg_info->output_components == 1) && (jpeg_info->quantize_colors == 0)) @@ -1319,7 +1320,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (AcquireImageColormap(image,colors,exception) == MagickFalse) { JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } } @@ -1345,16 +1346,16 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (jpeg_info->arith_code == TRUE) (void) SetImageProperty(image,"jpeg:coding","arithmetic",exception); #endif - if (JPEGSetImageProfiles(error_manager) == MagickFalse) + if (JPEGSetImageProfiles(client_info) == MagickFalse) { JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); return(DestroyImageList(image)); } if (image_info->ping != MagickFalse) { JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); (void) CloseBlob(image); return(GetFirstImageInList(image)); } @@ -1362,7 +1363,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (status == MagickFalse) { JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); return(DestroyImageList(image)); } (void) jpeg_start_decompress(jpeg_info); @@ -1370,7 +1371,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, (jpeg_info->output_components != 3) && (jpeg_info->output_components != 4)) { JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); ThrowReaderException(CorruptImageError,"ImageTypeNotSupported"); } memory_info=AcquireVirtualMemory((size_t) image->columns, @@ -1378,7 +1379,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, if (memory_info == (MemoryInfo *) NULL) { JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info); @@ -1387,12 +1388,12 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, /* Convert JPEG pixels to pixel packets. */ - if (setjmp(error_manager->error_recovery) != 0) + if (setjmp(client_info->error_recovery) != 0) { if (memory_info != (MemoryInfo *) NULL) memory_info=RelinquishVirtualMemory(memory_info); JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); (void) CloseBlob(image); number_pixels=(MagickSizeType) image->columns*image->rows; if (number_pixels != 0) @@ -1543,15 +1544,15 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, } if (status != MagickFalse) { - error_manager->finished=MagickTrue; - if (setjmp(error_manager->error_recovery) == 0) + client_info->finished=MagickTrue; + if (setjmp(client_info->error_recovery) == 0) (void) jpeg_finish_decompress(jpeg_info); } /* Free jpeg resources. */ JPEGDestroyDecompress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); memory_info=RelinquishVirtualMemory(memory_info); (void) CloseBlob(image); return(GetFirstImageInList(image)); @@ -1761,16 +1762,16 @@ static QuantizationTable *DestroyQuantizationTable(QuantizationTable *table) return(table); } -static boolean EmptyOutputBuffer(j_compress_ptr cinfo) +static boolean EmptyOutputBuffer(j_compress_ptr compress_info) { DestinationManager *destination; - destination=(DestinationManager *) cinfo->dest; + destination=(DestinationManager *) compress_info->dest; destination->manager.free_in_buffer=(size_t) WriteBlob(destination->image, MagickMinBufferExtent,destination->buffer); if (destination->manager.free_in_buffer != MagickMinBufferExtent) - ERREXIT(cinfo,JERR_FILE_WRITE); + ERREXIT(compress_info,JERR_FILE_WRITE); destination->manager.next_output_byte=destination->buffer; return(TRUE); } @@ -1969,24 +1970,25 @@ static QuantizationTable *GetQuantizationTable(const char *filename, return(table); } -static void InitializeDestination(j_compress_ptr cinfo) +static void InitializeDestination(j_compress_ptr compress_info) { DestinationManager *destination; - destination=(DestinationManager *) cinfo->dest; - destination->buffer=(JOCTET *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo,JPOOL_IMAGE,MagickMinBufferExtent*sizeof(JOCTET)); + destination=(DestinationManager *) compress_info->dest; + destination->buffer=(JOCTET *) (*compress_info->mem->alloc_small) ( + (j_common_ptr) compress_info,JPOOL_IMAGE,MagickMinBufferExtent* + sizeof(JOCTET)); destination->manager.next_output_byte=destination->buffer; destination->manager.free_in_buffer=MagickMinBufferExtent; } -static void TerminateDestination(j_compress_ptr cinfo) +static void TerminateDestination(j_compress_ptr compress_info) { DestinationManager *destination; - destination=(DestinationManager *) cinfo->dest; + destination=(DestinationManager *) compress_info->dest; if ((MagickMinBufferExtent-(int) destination->manager.free_in_buffer) > 0) { ssize_t @@ -1996,7 +1998,7 @@ static void TerminateDestination(j_compress_ptr cinfo) destination->manager.free_in_buffer,destination->buffer); if (count != (ssize_t) (MagickMinBufferExtent-destination->manager.free_in_buffer)) - ERREXIT(cinfo,JERR_FILE_WRITE); + ERREXIT(compress_info,JERR_FILE_WRITE); } } @@ -2138,14 +2140,15 @@ static void WriteProfile(j_compress_ptr jpeg_info,Image *image, custom_profile=DestroyStringInfo(custom_profile); } -static void JPEGDestinationManager(j_compress_ptr cinfo,Image * image) +static void JPEGDestinationManager(j_compress_ptr compress_info,Image * image) { DestinationManager *destination; - cinfo->dest=(struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo,JPOOL_IMAGE,sizeof(DestinationManager)); - destination=(DestinationManager *) cinfo->dest; + compress_info->dest=(struct jpeg_destination_mgr *) (* + compress_info->mem->alloc_small) ((j_common_ptr) compress_info,JPOOL_IMAGE, + sizeof(DestinationManager)); + destination=(DestinationManager *) compress_info->dest; destination->manager.init_destination=InitializeDestination; destination->manager.empty_output_buffer=EmptyOutputBuffer; destination->manager.term_destination=TerminateDestination; @@ -2206,9 +2209,6 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, *sampling_factor, *value; - ErrorManager - *error_manager; - Image *volatile volatile_image; @@ -2216,6 +2216,9 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, colorspace, quality; + JPEGClientInfo + *client_info; + JSAMPLE *volatile jpeg_pixels; @@ -2263,10 +2266,10 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, /* Initialize JPEG parameters. */ - error_manager=(ErrorManager *) AcquireMagickMemory(sizeof(*error_manager)); - if (error_manager == (ErrorManager *) NULL) + client_info=(JPEGClientInfo *) AcquireMagickMemory(sizeof(*client_info)); + if (client_info == (JPEGClientInfo *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); - (void) memset(error_manager,0,sizeof(*error_manager)); + (void) memset(client_info,0,sizeof(*client_info)); (void) memset(jpeg_info,0,sizeof(*jpeg_info)); (void) memset(&jpeg_error,0,sizeof(jpeg_error)); volatile_image=image; @@ -2274,17 +2277,17 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, jpeg_info->err=jpeg_std_error(&jpeg_error); jpeg_info->err->emit_message=(void (*)(j_common_ptr,int)) JPEGWarningHandler; jpeg_info->err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler; - error_manager->exception=exception; - error_manager->image=volatile_image; + client_info->exception=exception; + client_info->image=volatile_image; memory_info=(MemoryInfo *) NULL; - if (setjmp(error_manager->error_recovery) != 0) + if (setjmp(client_info->error_recovery) != 0) { jpeg_destroy_compress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); (void) CloseBlob(volatile_image); return(MagickFalse); } - jpeg_info->client_data=(void *) error_manager; + jpeg_info->client_data=(void *) client_info; jpeg_create_compress(jpeg_info); JPEGDestinationManager(jpeg_info,image); if ((image->columns != (unsigned int) image->columns) || @@ -2806,10 +2809,10 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, if (memory_info == (MemoryInfo *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info); - if (setjmp(error_manager->error_recovery) != 0) + if (setjmp(client_info->error_recovery) != 0) { jpeg_destroy_compress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); if (memory_info != (MemoryInfo *) NULL) memory_info=RelinquishVirtualMemory(memory_info); (void) CloseBlob(image); @@ -3004,7 +3007,7 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, Relinquish resources. */ jpeg_destroy_compress(jpeg_info); - error_manager=(ErrorManager *) RelinquishMagickMemory(error_manager); + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); memory_info=RelinquishVirtualMemory(memory_info); (void) CloseBlob(image); return(MagickTrue); From c958cda91d0e4256831f2f2ed303b38b14371fa2 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 19 Apr 2021 18:31:47 -0400 Subject: [PATCH 10/15] cosmetic --- coders/jpeg.c | 53 +++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/coders/jpeg.c b/coders/jpeg.c index 46ac4999c..11d493b62 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -1029,6 +1029,14 @@ static MagickBooleanType JPEGSetImageProfiles(JPEGClientInfo *client_info) static Image *ReadJPEGImage_(const ImageInfo *image_info, struct jpeg_decompress_struct *jpeg_info,ExceptionInfo *exception) { +#define ThrowJPEGReaderException(exception,message) \ +{ \ + JPEGDestroyDecompress(jpeg_info); \ + if (client_info != (JPEGClientInfo *) NULL) \ + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); \ + ThrowReaderException((exception),(message)); \ +} + char value[MagickPathExtent]; @@ -1040,7 +1048,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, *image; JPEGClientInfo - *client_info; + *client_info = (JPEGClientInfo *) NULL; JSAMPLE *volatile jpeg_pixels; @@ -1102,13 +1110,13 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, Verify that file size large enough to contain a JPEG datastream. */ if (GetBlobSize(image) < 107) - ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); + ThrowJPEGReaderException(CorruptImageError,"InsufficientImageDataInFile"); /* Initialize JPEG parameters. */ client_info=(JPEGClientInfo *) AcquireMagickMemory(sizeof(*client_info)); if (client_info == (JPEGClientInfo *) NULL) - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); + ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); (void) memset(client_info,0,sizeof(*client_info)); (void) memset(jpeg_info,0,sizeof(*jpeg_info)); (void) memset(&jpeg_error,0,sizeof(jpeg_error)); @@ -1306,11 +1314,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, option=GetImageOption(image_info,"jpeg:colors"); if (option != (const char *) NULL) if (AcquireImageColormap(image,StringToUnsignedLong(option),exception) == MagickFalse) - { - JPEGDestroyDecompress(jpeg_info); - client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); - } + ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); if ((jpeg_info->output_components == 1) && (jpeg_info->quantize_colors == 0)) { size_t @@ -1318,11 +1322,7 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, colors=(size_t) GetQuantumRange(image->depth)+1; if (AcquireImageColormap(image,colors,exception) == MagickFalse) - { - JPEGDestroyDecompress(jpeg_info); - client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); - } + ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); } if (image->debug != MagickFalse) { @@ -1369,19 +1369,11 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, (void) jpeg_start_decompress(jpeg_info); if ((jpeg_info->output_components != 1) && (jpeg_info->output_components != 3) && (jpeg_info->output_components != 4)) - { - JPEGDestroyDecompress(jpeg_info); - client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); - ThrowReaderException(CorruptImageError,"ImageTypeNotSupported"); - } + ThrowJPEGReaderException(CorruptImageError,"ImageTypeNotSupported"); memory_info=AcquireVirtualMemory((size_t) image->columns, jpeg_info->output_components*sizeof(*jpeg_pixels)); if (memory_info == (MemoryInfo *) NULL) - { - JPEGDestroyDecompress(jpeg_info); - client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); - ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); - } + ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info); (void) memset(jpeg_pixels,0,image->columns* jpeg_info->output_components*sizeof(*jpeg_pixels)); @@ -2203,6 +2195,13 @@ static char **SamplingFactorToList(const char *text) static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, Image *image,struct jpeg_compress_struct *jpeg_info,ExceptionInfo *exception) { +#define ThrowJPEGWriterException(exception,message) \ +{ \ + if (client_info != (JPEGClientInfo *) NULL) \ + client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); \ + ThrowWriterException((exception),(message)); \ +} + const char *dct_method, *option, @@ -2217,7 +2216,7 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, quality; JPEGClientInfo - *client_info; + *client_info = (JPEGClientInfo *) NULL; JSAMPLE *volatile jpeg_pixels; @@ -2268,7 +2267,7 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, */ client_info=(JPEGClientInfo *) AcquireMagickMemory(sizeof(*client_info)); if (client_info == (JPEGClientInfo *) NULL) - ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); + ThrowJPEGWriterException(ResourceLimitError,"MemoryAllocationFailed"); (void) memset(client_info,0,sizeof(*client_info)); (void) memset(jpeg_info,0,sizeof(*jpeg_info)); (void) memset(&jpeg_error,0,sizeof(jpeg_error)); @@ -2292,7 +2291,7 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, JPEGDestinationManager(jpeg_info,image); if ((image->columns != (unsigned int) image->columns) || (image->rows != (unsigned int) image->rows)) - ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit"); + ThrowJPEGWriterException(ImageError,"WidthOrHeightExceedsLimit"); jpeg_info->image_width=(unsigned int) image->columns; jpeg_info->image_height=(unsigned int) image->rows; jpeg_info->input_components=3; @@ -2807,7 +2806,7 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info, memory_info=AcquireVirtualMemory((size_t) image->columns, jpeg_info->input_components*sizeof(*jpeg_pixels)); if (memory_info == (MemoryInfo *) NULL) - ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); + ThrowJPEGWriterException(ResourceLimitError,"MemoryAllocationFailed"); jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info); if (setjmp(client_info->error_recovery) != 0) { From 26ad64d1b07613b022017fcc8e3d066a46c9215b Mon Sep 17 00:00:00 2001 From: Cristy Date: Tue, 20 Apr 2021 09:49:39 -0400 Subject: [PATCH 11/15] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33466 --- coders/jpeg.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/coders/jpeg.c b/coders/jpeg.c index 11d493b62..7d018c506 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -1031,7 +1031,6 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, { #define ThrowJPEGReaderException(exception,message) \ { \ - JPEGDestroyDecompress(jpeg_info); \ if (client_info != (JPEGClientInfo *) NULL) \ client_info=(JPEGClientInfo *) RelinquishMagickMemory(client_info); \ ThrowReaderException((exception),(message)); \ @@ -1314,7 +1313,10 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, option=GetImageOption(image_info,"jpeg:colors"); if (option != (const char *) NULL) if (AcquireImageColormap(image,StringToUnsignedLong(option),exception) == MagickFalse) - ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + JPEGDestroyDecompress(jpeg_info); + ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); + } if ((jpeg_info->output_components == 1) && (jpeg_info->quantize_colors == 0)) { size_t @@ -1322,7 +1324,10 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, colors=(size_t) GetQuantumRange(image->depth)+1; if (AcquireImageColormap(image,colors,exception) == MagickFalse) - ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + JPEGDestroyDecompress(jpeg_info); + ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); + } } if (image->debug != MagickFalse) { @@ -1369,11 +1374,17 @@ static Image *ReadJPEGImage_(const ImageInfo *image_info, (void) jpeg_start_decompress(jpeg_info); if ((jpeg_info->output_components != 1) && (jpeg_info->output_components != 3) && (jpeg_info->output_components != 4)) - ThrowJPEGReaderException(CorruptImageError,"ImageTypeNotSupported"); + { + JPEGDestroyDecompress(jpeg_info); + ThrowJPEGReaderException(CorruptImageError,"ImageTypeNotSupported"); + } memory_info=AcquireVirtualMemory((size_t) image->columns, jpeg_info->output_components*sizeof(*jpeg_pixels)); if (memory_info == (MemoryInfo *) NULL) - ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); + { + JPEGDestroyDecompress(jpeg_info); + ThrowJPEGReaderException(ResourceLimitError,"MemoryAllocationFailed"); + } jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info); (void) memset(jpeg_pixels,0,image->columns* jpeg_info->output_components*sizeof(*jpeg_pixels)); From 8006d367ecc1792bbe453092afeb5ab02558a55b Mon Sep 17 00:00:00 2001 From: Eric McConville Date: Tue, 20 Apr 2021 09:00:00 -0500 Subject: [PATCH 12/15] Added missing MagickSetImageMask header definition. (#3566) * Added missing MagickSetImageMask header definition * Slight alphabetize-order adjustement --- MagickWand/magick-image.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MagickWand/magick-image.h b/MagickWand/magick-image.h index 50365fcc3..52e5343ed 100644 --- a/MagickWand/magick-image.h +++ b/MagickWand/magick-image.h @@ -289,6 +289,7 @@ extern WandExport MagickBooleanType MagickSetImageInterlaceScheme(MagickWand *,const InterlaceType), MagickSetImageInterpolateMethod(MagickWand *,const PixelInterpolateMethod), MagickSetImageIterations(MagickWand *,const size_t), + MagickSetImageMask(MagickWand *,const PixelMask,const MagickWand *), MagickSetImageMatte(MagickWand *,const MagickBooleanType), MagickSetImageMatteColor(MagickWand *,const PixelWand *), MagickSetImageOrientation(MagickWand *,const OrientationType), From cdc1fd64e04a31841d32c23548382dad01edf6ec Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 24 Apr 2021 08:32:21 -0400 Subject: [PATCH 13/15] https://github.com/ImageMagick/ImageMagick/issues/3571 --- MagickCore/colorspace.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index cad2a7acd..07499cfb4 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -610,9 +610,10 @@ static MagickBooleanType sRGBTransformImage(Image *image, MagickRealType gray; - gray=0.212656*GetPixelRed(image,q)+0.715158*GetPixelGreen(image,q)+ - 0.072186*GetPixelBlue(image,q); - SetPixelGray(image,ClampToQuantum(DecodePixelGamma(gray)),q); + gray=0.212656*DecodePixelGamma(GetPixelRed(image,q))+0.715158* + DecodePixelGamma(GetPixelGreen(image,q))+0.072186* + DecodePixelGamma(GetPixelBlue(image,q)); + SetPixelGray(image,ClampToQuantum(gray),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); From d409ccb6e35890432209cb3e30ab0100b9d99a9c Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 24 Apr 2021 08:43:24 -0400 Subject: [PATCH 14/15] https://github.com/ImageMagick/ImageMagick/issues/3571 --- MagickCore/colorspace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index 07499cfb4..f9bcf5d03 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -2189,9 +2189,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, MagickRealType gray; - gray=0.212656*GetPixelRed(image,q)+0.715158*GetPixelGreen(image,q)+ - 0.072186*GetPixelBlue(image,q); - gray=EncodePixelGamma(gray); + gray=0.212656*EncodePixelGamma(GetPixelRed(image,q))+0.715158* + EncodePixelGamma(GetPixelGreen(image,q))+0.072186* + EncodePixelGamma(GetPixelBlue(image,q)); SetPixelRed(image,ClampToQuantum(gray),q); SetPixelGreen(image,ClampToQuantum(gray),q); SetPixelBlue(image,ClampToQuantum(gray),q); From 5bf34ccb171822c697f1ab7ce98c30ee0e10d2d1 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 24 Apr 2021 09:13:23 -0400 Subject: [PATCH 15/15] pending release --- ChangeLog | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a49f89eaf..e56561aa5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ 2021-04-17 7.0.11-9 * Release ImageMagick version 7.0.11-9 GIT revision 18... -2021-04-17 7.0.11-8 +2021-04-17 7.0.11-9 * eliminate uninitialized value + * Differences in computing linear gray (reference + https://github.com/ImageMagick/ImageMagick/issues/3571). 2021-04-17 7.0.11-8 * Release ImageMagick version 7.0.11-8 GIT revision 18636:53a252607:20210417