Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(862)

Side by Side Diff: third_party/lcms2-2.6/0011-memory-leak-ReadSegmentedCurve.patch

Issue 2480013002: lcms: Fix memory leak in ReadSegmentedCurve (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/lcms2-2.6/README.pdfium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 diff --git a/third_party/lcms2-2.6/src/cmstypes.c b/third_party/lcms2-2.6/src/cm stypes.c
2 index 15199c7..04dd0c4 100644
3 --- a/third_party/lcms2-2.6/src/cmstypes.c
4 +++ b/third_party/lcms2-2.6/src/cmstypes.c
5 @@ -3968,7 +3968,7 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_s truct* 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_s truct* self, cmsIOHAND
15 _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
16 cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Un known 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
OLDNEW
« no previous file with comments | « no previous file | third_party/lcms2-2.6/README.pdfium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698