From 4d6b920cfea41467a1179e8a53a66b3d6f8438dc Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Thu, 25 Apr 2024 12:34:59 +0200 Subject: [PATCH] Added version checks for itxt_length in the png coder. --- coders/png.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/coders/png.c b/coders/png.c index 5baa7d48d..19dfd3ab8 100644 --- a/coders/png.c +++ b/coders/png.c @@ -8258,22 +8258,25 @@ static void Magick_png_set_text(png_struct *ping,png_info *ping_info, MngInfo *mng_info,const ImageInfo *image_info,const char *key, const char *value) { +#if PNG_LIBPNG_VER >= 10600 const char *c; + MagickBooleanType + write_itxt=MagickFalse; +#endif + int compresion_none = PNG_TEXT_COMPRESSION_NONE, compresion_zTXt = PNG_TEXT_COMPRESSION_zTXt; - MagickBooleanType - write_itxt=MagickFalse; - png_textp text; size_t length; +#if PNG_LIBPNG_VER >= 10600 /* Check if the string contains non-Latin1 characters. */ @@ -8288,6 +8291,7 @@ static void Magick_png_set_text(png_struct *ping,png_info *ping_info, } c++; } +#endif #if PNG_LIBPNG_VER >= 10400 text=(png_textp) png_malloc(ping,(png_alloc_size_t) sizeof(png_text)); #else @@ -8299,10 +8303,12 @@ static void Magick_png_set_text(png_struct *ping,png_info *ping_info, text[0].key=(char *) key; text[0].text=(char *) value; length=strlen(value); - if (write_itxt == MagickFalse) - text[0].text_length=length; - else +#if PNG_LIBPNG_VER >= 10600 + if (write_itxt != MagickFalse) text[0].itxt_length=length; + else +#endif + text[0].text_length=length; if (mng_info->ping_exclude_tEXt != MagickFalse) text[0].compression=compresion_zTXt; else