diff --git a/src/cmsps2.c b/src/cmsps2.c index 70e4ea8d..20e0899a 100644 --- a/src/cmsps2.c +++ b/src/cmsps2.c @@ -980,10 +980,15 @@ int WriteNamedColorCSA(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number hLab = cmsCreateLab4ProfileTHR(m ->ContextID, NULL); xform = cmsCreateTransform(hNamedColor, TYPE_NAMED_COLOR_INDEX, hLab, TYPE_Lab_DBL, Intent, 0); + cmsCloseProfile(hLab); + if (xform == NULL) return 0; NamedColorList = cmsGetNamedColorList(xform); - if (NamedColorList == NULL) return 0; + if (NamedColorList == NULL) { + cmsDeleteTransform(xform); + return 0; + } _cmsIOPrintf(m, "<<\n"); _cmsIOPrintf(m, "(colorlistcomment) (%s)\n", "Named color CSA"); @@ -992,7 +997,6 @@ int WriteNamedColorCSA(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number nColors = cmsNamedColorCount(NamedColorList); - for (i=0; i < nColors; i++) { cmsUInt16Number In[1]; @@ -1007,12 +1011,9 @@ int WriteNamedColorCSA(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number _cmsIOPrintf(m, " (%s) [ %.3f %.3f %.3f ]\n", ColorName, Lab.L, Lab.a, Lab.b); } - - _cmsIOPrintf(m, ">>\n"); cmsDeleteTransform(xform); - cmsCloseProfile(hLab); return 1; } @@ -1404,7 +1405,10 @@ int WriteNamedColorCRD(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number NamedColorList = cmsGetNamedColorList(xform); - if (NamedColorList == NULL) return 0; + if (NamedColorList == NULL) { + cmsDeleteTransform(xform); + return 0; + } _cmsIOPrintf(m, "<<\n"); _cmsIOPrintf(m, "(colorlistcomment) (%s) \n", "Named profile");