Skip to content

Commit

Permalink
Merge pull request #401 from sebras/master
Browse files Browse the repository at this point in the history
Fix memory leak in case tone curve not successfully allocated.
Looks great, thank you!
  • Loading branch information
mm2 authored Sep 12, 2023
2 parents f207d2a + 2d54327 commit 02ec54b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cmsgamma.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ cmsToneCurve* AllocateToneCurveStruct(cmsContext ContextID, cmsUInt32Number nEnt
return p;

Error:
for (i=0; i < nSegments; i++) {
if (p ->Segments && p ->Segments[i].SampledPoints) _cmsFree(ContextID, p ->Segments[i].SampledPoints);
if (p ->SegInterp && p ->SegInterp[i]) _cmsFree(ContextID, p ->SegInterp[i]);
}
if (p -> SegInterp) _cmsFree(ContextID, p -> SegInterp);
if (p -> Segments) _cmsFree(ContextID, p -> Segments);
if (p -> Evals) _cmsFree(ContextID, p -> Evals);
Expand Down

0 comments on commit 02ec54b

Please sign in to comment.