From e75ebf3c9b30444948a90ad59e8cd83ea1f28e38 Mon Sep 17 00:00:00 2001
From: Cristy <urban-warrior@imagemagick.org>
Date: Thu, 19 Jan 2017 19:30:48 -0500
Subject: [PATCH] Fix an assertion faillure in TGA

bug: https://github.com/ImageMagick/ImageMagick/pull/359
bug-debian: https://bugs.debian.org/856878
origin: https://github.com/ImageMagick/ImageMagick/commit/65f75a32a93ae4044c528a987a68366ecd4b46b9

(cherry picked from commit 65f75a32a93ae4044c528a987a68366ecd4b46b9)
---
 coders/tga.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/coders/tga.c b/coders/tga.c
index 6d6b07011..97e2d52dd 100644
--- a/coders/tga.c
+++ b/coders/tga.c
@@ -684,6 +684,7 @@ static MagickBooleanType WriteTGAImage(const ImageInfo *image_info,
     compression;
 
   const char
+    *comment,
     *value;
 
   MagickBooleanType
@@ -733,9 +734,9 @@ static MagickBooleanType WriteTGAImage(const ImageInfo *image_info,
   if (image_info->compression != UndefinedCompression)
     compression=image_info->compression;
   tga_info.id_length=0;
-  value=GetImageProperty(image,"comment");
-  if (value != (const char *) NULL)
-    tga_info.id_length=(unsigned char) MagickMin(strlen(value),255);
+  comment=GetImageProperty(image,"comment");
+  if (comment != (const char *) NULL)
+    tga_info.id_length=(unsigned char) MagickMin(strlen(comment),255);
   tga_info.colormap_type=0;
   tga_info.colormap_index=0;
   tga_info.colormap_length=0;
@@ -795,7 +796,7 @@ static MagickBooleanType WriteTGAImage(const ImageInfo *image_info,
   (void) WriteBlobByte(image,tga_info.bits_per_pixel);
   (void) WriteBlobByte(image,tga_info.attributes);
   if (tga_info.id_length != 0)
-    (void) WriteBlob(image,tga_info.id_length,(unsigned char *) value);
+    (void) WriteBlob(image,tga_info.id_length,(unsigned char *) comment);
   if (tga_info.colormap_type != 0)
     {
       unsigned char
