From b61d35eaccc0a7ddeff8a1c3abfcd0a43ccf210b Mon Sep 17 00:00:00 2001 From: Cristy Date: Wed, 9 Nov 2016 15:57:28 -0500 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/298 --- MagickCore/property.c | 4 ++-- coders/tiff.c | 43 ++++++++++++++++++++++++++++--------------- coders/txt.c | 3 +-- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/MagickCore/property.c b/MagickCore/property.c index 2a80dc2a9..39fcb8ce7 100644 --- a/MagickCore/property.c +++ b/MagickCore/property.c @@ -213,7 +213,7 @@ MagickExport MagickBooleanType CloneImageProperties(Image *image, % % DefineImageProperty() associates an assignment string of the form % "key=value" with an artifact or options. It is equivelent to -% SetImageProperty() +% SetImageProperty(). % % The format of the DefineImageProperty method is: % @@ -3962,7 +3962,7 @@ MagickExport MagickBooleanType SetImageProperty(Image *image, { /* Do not 'set' single letter properties - read only shorthand. - */ + */ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "SetReadOnlyProperty","`%s'",property); return(MagickFalse); diff --git a/coders/tiff.c b/coders/tiff.c index feffff277..e108920f3 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -631,42 +631,54 @@ static void TIFFGetProperties(TIFF *tiff,Image *image,ExceptionInfo *exception) unsigned long *tietz; - - if (TIFFGetField(tiff,TIFFTAG_ARTIST,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_ARTIST,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"tiff:artist",text,exception); - if (TIFFGetField(tiff,TIFFTAG_COPYRIGHT,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_COPYRIGHT,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"tiff:copyright",text,exception); - if (TIFFGetField(tiff,TIFFTAG_DATETIME,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_DATETIME,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"tiff:timestamp",text,exception); - if (TIFFGetField(tiff,TIFFTAG_DOCUMENTNAME,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_DOCUMENTNAME,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"tiff:document",text,exception); - if (TIFFGetField(tiff,TIFFTAG_HOSTCOMPUTER,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_HOSTCOMPUTER,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"tiff:hostcomputer",text,exception); - if (TIFFGetField(tiff,TIFFTAG_IMAGEDESCRIPTION,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_IMAGEDESCRIPTION,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"comment",text,exception); - if (TIFFGetField(tiff,TIFFTAG_MAKE,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_MAKE,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"tiff:make",text,exception); - if (TIFFGetField(tiff,TIFFTAG_MODEL,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_MODEL,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"tiff:model",text,exception); - if (TIFFGetField(tiff,TIFFTAG_OPIIMAGEID,&count,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_OPIIMAGEID,&count,&text) == 1) && + (text != (char *) NULL)) { if (count >= MagickPathExtent) count=MagickPathExtent-1; (void) CopyMagickString(message,text,count+1); (void) SetImageProperty(image,"tiff:image-id",message,exception); } - if (TIFFGetField(tiff,TIFFTAG_PAGENAME,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_PAGENAME,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"label",text,exception); - if (TIFFGetField(tiff,TIFFTAG_SOFTWARE,&text) == 1) + if ((TIFFGetField(tiff,TIFFTAG_SOFTWARE,&text) == 1) && + (text != (char *) NULL)) (void) SetImageProperty(image,"tiff:software",text,exception); - if (TIFFGetField(tiff,33423,&count,&text) == 1) + if ((TIFFGetField(tiff,33423,&count,&text) == 1) && + (text != (char *) NULL)) { if (count >= MagickPathExtent) count=MagickPathExtent-1; (void) CopyMagickString(message,text,count+1); (void) SetImageProperty(image,"tiff:kodak-33423",message,exception); } - if (TIFFGetField(tiff,36867,&count,&text) == 1) + if ((TIFFGetField(tiff,36867,&count,&text) == 1) && + (text != (char *) NULL)) { if (count >= MagickPathExtent) count=MagickPathExtent-1; @@ -695,7 +707,8 @@ static void TIFFGetProperties(TIFF *tiff,Image *image,ExceptionInfo *exception) default: break; } - if (TIFFGetField(tiff,37706,&length,&tietz) == 1) + if ((TIFFGetField(tiff,37706,&length,&tietz) == 1) && + (tietz != (unsigned long *) NULL)) { (void) FormatLocaleString(message,MagickPathExtent,"%lu",tietz[0]); (void) SetImageProperty(image,"tiff:tietz_offset",message,exception); diff --git a/coders/txt.c b/coders/txt.c index 74d496bea..7d0dbb2e2 100644 --- a/coders/txt.c +++ b/coders/txt.c @@ -793,8 +793,7 @@ static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image, (void) WriteBlobString(image,buffer); (void) CopyMagickString(tuple,"(",MagickPathExtent); if (pixel.colorspace == GRAYColorspace) - ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance, - tuple); + ConcatenateColorComponent(&pixel,GrayPixelChannel,compliance,tuple); else { ConcatenateColorComponent(&pixel,RedPixelChannel,compliance,tuple); -- 2.40.0