From 0b03786b366667fabf2ae20012545857bb03dae5 Mon Sep 17 00:00:00 2001
From: Richard Hughes <richard@hughsie.com>
Date: Tue, 18 Jun 2013 09:46:17 +0100
Subject: [PATCH] Do not assert on profiles with invalid dictionary metadata

Daemons like colord might be parsing invalid profiles, and asserting cannot be
handled if lcms is in process.
---
 src/cmsnamed.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/cmsnamed.c b/src/cmsnamed.c
index a916e17..5ac1b53 100644
--- a/src/cmsnamed.c
+++ b/src/cmsnamed.c
@@ -865,7 +865,14 @@ cmsBool CMSEXPORT cmsDictAddEntry(cmsHANDLE hDict, const wchar_t* Name, const wc
     cmsDICTentry *entry;
 
     _cmsAssert(dict != NULL);
-    _cmsAssert(Name != NULL);
+
+    /* cannot be NULL, unless the profile is corrupt */
+    if (Name == NULL) {
+        cmsSignalError(dict ->ContextID,
+                       cmsERROR_CORRUPTION_DETECTED,
+                       "dictionary entry name cannot be NULL");
+        return FALSE;
+    }
 
     entry = (cmsDICTentry*) _cmsMallocZero(dict ->ContextID, sizeof(cmsDICTentry));
     if (entry == NULL) return FALSE;
-- 
1.8.2.1

