1diff --git a/third_party/lcms/src/cmscgats.c b/third_party/lcms/src/cmscgats.c 2index a0c25c024..55f74ede8 100644 3--- a/third_party/lcms/src/cmscgats.c 4+++ b/third_party/lcms/src/cmscgats.c 5@@ -38,7 +38,10 @@ 6 #define DEFAULT_DBL_FORMAT "%.10g" // Double formatting 7 8 #ifdef CMS_IS_WINDOWS_ 9-# include <io.h> 10+//sunliang.liu modified 2010426 for wince error 11+# ifndef _WIN32_WCE 12+# include <io.h> 13+# endif 14 # define DIR_CHAR '\\' 15 #else 16 # define DIR_CHAR '/' 17diff --git a/third_party/lcms/src/cmsgamma.c b/third_party/lcms/src/cmsgamma.c 18index eb3dd881c..6e36cf462 100644 19--- a/third_party/lcms/src/cmsgamma.c 20+++ b/third_party/lcms/src/cmsgamma.c 21@@ -749,14 +749,19 @@ void CMSEXPORT cmsFreeToneCurve(cmsToneCurve* Curve) 22 { 23 cmsContext ContextID; 24 25- if (Curve == NULL) return; 26+ // added by Xiaochuan Liu 27+ // Curve->InterpParams may be null 28+ if (Curve == NULL || Curve->InterpParams == NULL) return; 29 30 ContextID = Curve ->InterpParams->ContextID; 31 32 _cmsFreeInterpParams(Curve ->InterpParams); 33+ Curve ->InterpParams = NULL; 34 35- if (Curve -> Table16) 36+ if (Curve -> Table16) { 37 _cmsFree(ContextID, Curve ->Table16); 38+ Curve ->Table16 = NULL; 39+ } 40 41 if (Curve ->Segments) { 42 43@@ -876,18 +881,25 @@ void CMSEXPORT cmsFreeToneCurve(cmsToneCurve* Curve) 44 45 if (Curve ->Segments[i].SampledPoints) { 46 _cmsFree(ContextID, Curve ->Segments[i].SampledPoints); 47+ Curve ->Segments[i].SampledPoints = NULL; 48 } 49 50- if (Curve ->SegInterp[i] != 0) 51+ if (Curve ->SegInterp[i] != 0) { 52 _cmsFreeInterpParams(Curve->SegInterp[i]); 53+ Curve->SegInterp[i] = NULL; 54+ } 55 } 56 57 _cmsFree(ContextID, Curve ->Segments); 58+ Curve ->Segments = NULL; 59 _cmsFree(ContextID, Curve ->SegInterp); 60+ Curve ->SegInterp = NULL; 61 } 62 63- if (Curve -> Evals) 64+ if (Curve -> Evals) { 65 _cmsFree(ContextID, Curve -> Evals); 66+ Curve -> Evals = NULL; 67+ } 68 69 _cmsFree(ContextID, Curve); 70 } 71diff --git a/third_party/lcms/src/cmsio0.c b/third_party/lcms/src/cmsio0.c 72index 1b026488d..cc5f89064 100644 73--- a/third_party/lcms/src/cmsio0.c 74+++ b/third_party/lcms/src/cmsio0.c 75@@ -479,6 +479,14 @@ cmsIOHANDLER* CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile) 76 return Icc->IOhandler; 77 } 78 79+#ifdef _WIN32_WCE 80+time_t wceex_time(time_t *timer); 81+struct tm * wceex_gmtime(const time_t *timer); 82+ 83+#define time wceex_time 84+#define gmtime wceex_gmtime 85+#endif 86+ 87 // Creates an empty structure holding all required parameters 88 cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID) 89 { 90@@ -570,6 +578,14 @@ int _cmsSearchTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, cmsBool lFollowLinks 91 92 // Yes, follow link 93 if (LinkedSig != (cmsTagSignature) 0) { 94+ // fix bug mantis id#0055942 95+ // assume that TRCTag and ColorantTag can't be linked. 96+ // Xiaochuan Liu 2014-04-23 97+ if ((sig == cmsSigRedTRCTag || sig == cmsSigGreenTRCTag || sig == cmsSigBlueTRCTag) && 98+ (LinkedSig == cmsSigRedColorantTag || LinkedSig == cmsSigGreenColorantTag || LinkedSig == cmsSigBlueColorantTag)) 99+ { 100+ return n; 101+ } 102 sig = LinkedSig; 103 } 104 105@@ -1363,6 +1379,12 @@ Error: 106 return 0; 107 } 108 109+#ifdef _WIN32_WCE 110+int wceex_unlink(const char *filename); 111+#ifndef remove 112+# define remove wceex_unlink 113+#endif 114+#endif 115 116 // Low-level save to disk. 117 cmsBool CMSEXPORT cmsSaveProfileToFile(cmsHPROFILE hProfile, const char* FileName) 118