summaryrefslogtreecommitdiff
path: root/src/cmsnamed.c
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2016-12-06 22:13:35 +0100
committerMarti Maria <info@littlecms.com>2016-12-06 22:13:50 +0100
commita3def7562bd72961b8dffb1aa601e304952a778c (patch)
tree709d51b767ed8b61782ec5a0c81b047e572eac19 /src/cmsnamed.c
parent422f50dd6e3bff83be6f4b2c6ed0f1a0524abd6d (diff)
downloadlcms2-a3def7562bd72961b8dffb1aa601e304952a778c.tar.gz
non-happy path fixes
Fix leak from named color list error recovery Sanitize maximum string in CGATS parser
Diffstat (limited to 'src/cmsnamed.c')
-rw-r--r--src/cmsnamed.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cmsnamed.c b/src/cmsnamed.c
index 9b27ca0..a8ed7ff 100644
--- a/src/cmsnamed.c
+++ b/src/cmsnamed.c
@@ -517,7 +517,11 @@ cmsBool GrowNamedColorList(cmsNAMEDCOLORLIST* v)
size = v ->Allocated * 2;
// Keep a maximum color lists can grow, 100K entries seems reasonable
- if (size > 1024*100) return FALSE;
+ if (size > 1024 * 100) {
+ _cmsFree(v->ContextID, (void*) v->List);
+ v->List = NULL;
+ return FALSE;
+ }
NewPtr = (_cmsNAMEDCOLOR*) _cmsRealloc(v ->ContextID, v ->List, size * sizeof(_cmsNAMEDCOLOR));
if (NewPtr == NULL)
@@ -539,8 +543,11 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUIn
v ->nColors = 0;
v ->ContextID = ContextID;
- while (v -> Allocated < n){
- if (!GrowNamedColorList(v)) return NULL;
+ while (v -> Allocated < n) {
+ if (!GrowNamedColorList(v)) {
+ _cmsFree(ContextID, (void*) v);
+ return NULL;
+ }
}
strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)-1);