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

Side by Side Diff: third_party/lcms2-2.6/src/cmstypes.c

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 | « third_party/lcms2-2.6/README.pdfium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //------------------------------------------------------------------------------ --- 1 //------------------------------------------------------------------------------ ---
2 // 2 //
3 // Little Color Management System 3 // Little Color Management System
4 // Copyright (c) 1998-2014 Marti Maria Saguer 4 // Copyright (c) 1998-2014 Marti Maria Saguer
5 // 5 //
6 // Permission is hereby granted, free of charge, to any person obtaining 6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the "Software"), 7 // a copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation 8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e
(...skipping 3950 matching lines...) Expand 10 before | Expand all | Expand 10 after
3961 if (!_cmsReadFloat32Number(io, &f)) goto Error; 3961 if (!_cmsReadFloat32Number(io, &f)) goto Error;
3962 Segments[i].Params[j] = f; 3962 Segments[i].Params[j] = f;
3963 } 3963 }
3964 } 3964 }
3965 break; 3965 break;
3966 3966
3967 3967
3968 case cmsSigSampledCurveSeg: { 3968 case cmsSigSampledCurveSeg: {
3969 cmsUInt32Number Count; 3969 cmsUInt32Number Count;
3970 3970
3971 if (!_cmsReadUInt32Number(io, &Count)) return NULL; 3971 if (!_cmsReadUInt32Number(io, &Count)) goto Error;
3972 3972
3973 Segments[i].nGridPoints = Count; 3973 Segments[i].nGridPoints = Count;
3974 Segments[i].SampledPoints = (cmsFloat32Number*) _cmsCalloc(self ->ContextID, Count, sizeof(cmsFloat32Number)); 3974 Segments[i].SampledPoints = (cmsFloat32Number*) _cmsCalloc(self ->ContextID, Count, sizeof(cmsFloat32Number));
3975 if (Segments[i].SampledPoints == NULL) goto Error; 3975 if (Segments[i].SampledPoints == NULL) goto Error;
3976 3976
3977 for (j=0; j < Count; j++) { 3977 for (j=0; j < Count; j++) {
3978 if (!_cmsReadFloat32Number(io, &Segments[i].SampledPoints[j] )) goto Error; 3978 if (!_cmsReadFloat32Number(io, &Segments[i].SampledPoints[j] )) goto Error;
3979 } 3979 }
3980 } 3980 }
3981 break; 3981 break;
3982 3982
3983 default: 3983 default:
3984 { 3984 {
3985 char String[5]; 3985 char String[5];
3986 3986
3987 _cmsTagSignature2String(String, (cmsTagSignature) ElementSig); 3987 _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
3988 cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unk nown curve element type '%s' found.", String); 3988 cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unk nown curve element type '%s' found.", String);
3989 } 3989 }
3990 return NULL; 3990 goto Error;
3991 3991
3992 } 3992 }
3993 } 3993 }
3994 3994
3995 Curve = cmsBuildSegmentedToneCurve(self ->ContextID, nSegments, Segments); 3995 Curve = cmsBuildSegmentedToneCurve(self ->ContextID, nSegments, Segments);
3996 3996
3997 for (i=0; i < nSegments; i++) { 3997 for (i=0; i < nSegments; i++) {
3998 if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[i].S ampledPoints); 3998 if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[i].S ampledPoints);
3999 } 3999 }
4000 _cmsFree(self ->ContextID, Segments); 4000 _cmsFree(self ->ContextID, Segments);
4001 return Curve; 4001 return Curve;
4002 4002
4003 Error: 4003 Error:
4004 if (Segments) _cmsFree(self ->ContextID, Segments); 4004 if (Segments) {
4005 for (i=0; i < nSegments; i++) {
4006 if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[ i].SampledPoints);
4007 }
4008 _cmsFree(self ->ContextID, Segments);
4009 }
4005 return NULL; 4010 return NULL;
4006 } 4011 }
4007 4012
4008 4013
4009 static 4014 static
4010 cmsBool ReadMPECurve(struct _cms_typehandler_struct* self, 4015 cmsBool ReadMPECurve(struct _cms_typehandler_struct* self,
4011 cmsIOHANDLER* io, 4016 cmsIOHANDLER* io,
4012 void* Cargo, 4017 void* Cargo,
4013 cmsUInt32Number n, 4018 cmsUInt32Number n,
4014 cmsUInt32Number SizeOfTag) 4019 cmsUInt32Number SizeOfTag)
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after
5570 5575
5571 for (pt = SupportedTags; 5576 for (pt = SupportedTags;
5572 pt != NULL; 5577 pt != NULL;
5573 pt = pt ->Next) { 5578 pt = pt ->Next) {
5574 5579
5575 if (sig == pt -> Signature) return &pt ->Descriptor; 5580 if (sig == pt -> Signature) return &pt ->Descriptor;
5576 } 5581 }
5577 5582
5578 return NULL; 5583 return NULL;
5579 } 5584 }
OLDNEW
« no previous file with comments | « third_party/lcms2-2.6/README.pdfium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698