1 diff --git a/third_party/lcms/src/cmstypes.c b/third_party/lcms/src/cmstypes.c 2 index 06742b5..9fe5e2a 100644 3 --- a/third_party/lcms/src/cmstypes.c 4 +++ b/third_party/lcms/src/cmstypes.c 5 @@ -1112,7 +1112,10 @@ void *Type_Curve_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cm 6 NewGamma = cmsBuildTabulatedToneCurve16(self ->ContextID, Count, NULL); 7 if (!NewGamma) return NULL; 8 9 - if (!_cmsReadUInt16Array(io, Count, NewGamma -> Table16)) return NULL; 10 + if (!_cmsReadUInt16Array(io, Count, NewGamma -> Table16)) { 11 + cmsFreeToneCurve(NewGamma); 12 + return NULL; 13 + } 14 15 *nItems = 1; 16 return NewGamma; 17 @@ -2350,7 +2353,10 @@ cmsStage* ReadCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUI 18 19 for (i=0; i < Data ->nEntries; i++) { 20 21 - if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) return NULL; 22 + if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) { 23 + cmsStageFree(CLUT); 24 + return NULL; 25 + } 26 Data ->Tab.T[i] = FROM_8_TO_16(v); 27 } 28 29