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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/lcms2-2.6/README.pdfium » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/lcms2-2.6/0011-memory-leak-ReadSegmentedCurve.patch
diff --git a/third_party/lcms2-2.6/0011-memory-leak-ReadSegmentedCurve.patch b/third_party/lcms2-2.6/0011-memory-leak-ReadSegmentedCurve.patch
new file mode 100644
index 0000000000000000000000000000000000000000..a6cfe02b8c93b35fe10685f529837e5c72713db1
--- /dev/null
+++ b/third_party/lcms2-2.6/0011-memory-leak-ReadSegmentedCurve.patch
@@ -0,0 +1,36 @@
+diff --git a/third_party/lcms2-2.6/src/cmstypes.c b/third_party/lcms2-2.6/src/cmstypes.c
+index 15199c7..04dd0c4 100644
+--- a/third_party/lcms2-2.6/src/cmstypes.c
++++ b/third_party/lcms2-2.6/src/cmstypes.c
+@@ -3968,7 +3968,7 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHAND
+ case cmsSigSampledCurveSeg: {
+ cmsUInt32Number Count;
+
+- if (!_cmsReadUInt32Number(io, &Count)) return NULL;
++ if (!_cmsReadUInt32Number(io, &Count)) goto Error;
+
+ Segments[i].nGridPoints = Count;
+ Segments[i].SampledPoints = (cmsFloat32Number*) _cmsCalloc(self ->ContextID, Count, sizeof(cmsFloat32Number));
+@@ -3987,7 +3987,7 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHAND
+ _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
+ cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve element type '%s' found.", String);
+ }
+- return NULL;
++ goto Error;
+
+ }
+ }
+@@ -4001,7 +4001,12 @@ cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHAND
+ return Curve;
+
+ Error:
+- if (Segments) _cmsFree(self ->ContextID, Segments);
++ if (Segments) {
++ for (i=0; i < nSegments; i++) {
++ if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[i].SampledPoints);
++ }
++ _cmsFree(self ->ContextID, Segments);
++ }
+ return NULL;
+ }
+
« 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