Nicolas Pena | f752039 | 2017-08-10 16:36:56 -0400 | [diff] [blame] | 1 | diff --git a/third_party/lcms/src/cmstypes.c b/third_party/lcms/src/cmstypes.c |
kcwu | 5756a77 | 2016-11-07 08:42:15 -0800 | [diff] [blame] | 2 | index 15199c7..04dd0c4 100644 |
Nicolas Pena | f752039 | 2017-08-10 16:36:56 -0400 | [diff] [blame] | 3 | --- a/third_party/lcms/src/cmstypes.c |
| 4 | +++ b/third_party/lcms/src/cmstypes.c |
kcwu | 5756a77 | 2016-11-07 08:42:15 -0800 | [diff] [blame] | 5 | @@ -3968,7 +3968,7 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHAND |
| 6 | case cmsSigSampledCurveSeg: { |
| 7 | cmsUInt32Number Count; |
| 8 | |
| 9 | - if (!_cmsReadUInt32Number(io, &Count)) return NULL; |
| 10 | + if (!_cmsReadUInt32Number(io, &Count)) goto Error; |
| 11 | |
| 12 | Segments[i].nGridPoints = Count; |
| 13 | Segments[i].SampledPoints = (cmsFloat32Number*) _cmsCalloc(self ->ContextID, Count, sizeof(cmsFloat32Number)); |
| 14 | @@ -3987,7 +3987,7 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHAND |
| 15 | _cmsTagSignature2String(String, (cmsTagSignature) ElementSig); |
| 16 | cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve element type '%s' found.", String); |
| 17 | } |
| 18 | - return NULL; |
| 19 | + goto Error; |
| 20 | |
| 21 | } |
| 22 | } |
| 23 | @@ -4001,7 +4001,12 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHAND |
| 24 | return Curve; |
| 25 | |
| 26 | Error: |
| 27 | - if (Segments) _cmsFree(self ->ContextID, Segments); |
| 28 | + if (Segments) { |
| 29 | + for (i=0; i < nSegments; i++) { |
| 30 | + if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[i].SampledPoints); |
| 31 | + } |
| 32 | + _cmsFree(self ->ContextID, Segments); |
| 33 | + } |
| 34 | return NULL; |
| 35 | } |
| 36 | |