From da74f731c2b666d87f5fc0f99d74853d23d617c7 Mon Sep 17 00:00:00 2001
From: cristy <cristy@aa41f4f7-0bf4-0310-aa73-e5a19afd5a74>
Date: Fri, 28 Nov 2014 17:13:45 +0000
Subject: [PATCH] Avoid a NULL dereference in ps handling

GetStringInfoDatum(NULL) will likely crash. Avoid it.

git-svn-id: https://subversion.imagemagick.org/subversion/ImageMagick/branches/ImageMagick-6@17117 aa41f4f7-0bf4-0310-aa73-e5a19afd5a74
origin: http://trac.imagemagick.org/changeset/17117
---
 coders/ps.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/coders/ps.c b/coders/ps.c
index cc6c747..30fc3bb 100644
--- a/coders/ps.c
+++ b/coders/ps.c
@@ -555,11 +555,14 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
           continue;
         length=extent;
         profile=AcquireStringInfo(length);
-        p=GetStringInfoDatum(profile);
-        for (i=0; i < (long) length; i++)
-          *p++=(unsigned char) ProfileInteger(image,hex_digits);
-        (void) SetImageProfile(image,"8bim",profile);
-        profile=DestroyStringInfo(profile);
+	if (profile != (StringInfo *) NULL)
+	  {
+            p=GetStringInfoDatum(profile);
+	    for (i=0; i < (long) length; i++)
+	      *p++=(unsigned char) ProfileInteger(image,hex_digits);
+	    (void) SetImageProfile(image,"8bim",profile);
+	    profile=DestroyStringInfo(profile);
+	  }
         continue;
       }
     if (LocaleNCompare(BeginXMPPacket,command,strlen(BeginXMPPacket)) == 0)
-- 
2.1.4

