Skip to content
Permalink
Browse files Browse the repository at this point in the history
Non happy-path fixes
  • Loading branch information
Marti Maria committed Jun 25, 2013
1 parent 0ba8f90 commit 91c2db7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -120,6 +120,7 @@ Added support for VS2012
Added a simple project for cppcheck
Rendering intent used when creating the transform is now propagated to profile header in cmsTransform2Devicelink. This is because 7.2.15 in spec 4.3
Transform2Devicelink now keeps white point when guessing deviceclass is enabled
Added some checks for non-happy path, mostly failing mallocs

-----------------------
2.5 Maintenance release
Expand Down
12 changes: 7 additions & 5 deletions src/cmsnamed.c
Expand Up @@ -517,8 +517,8 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUIn
while (v -> Allocated < n)
GrowNamedColorList(v);

strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix));
strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix));
strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)-1);
strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix)-1);
v->Prefix[32] = v->Suffix[32] = 0;

v -> ColorantCount = ColorantCount;
Expand Down Expand Up @@ -577,9 +577,7 @@ cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* NamedColorList,

if (Name != NULL) {

strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name,
sizeof(NamedColorList ->List[NamedColorList ->nColors].Name));

strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name, cmsMAX_PATH-1);
NamedColorList ->List[NamedColorList ->nColors].Name[cmsMAX_PATH-1] = 0;

}
Expand Down Expand Up @@ -735,6 +733,10 @@ cmsSEQ* CMSEXPORT cmsAllocProfileSequenceDescription(cmsContext ContextID, cmsUI
Seq -> seq = (cmsPSEQDESC*) _cmsCalloc(ContextID, n, sizeof(cmsPSEQDESC));
Seq -> n = n;

if (Seq -> seq == NULL) {
_cmsFree(ContextID, Seq);
return NULL;
}

for (i=0; i < n; i++) {
Seq -> seq[i].Manufacturer = NULL;
Expand Down
10 changes: 10 additions & 0 deletions src/cmsopt.c
Expand Up @@ -1179,6 +1179,16 @@ Curves16Data* CurvesAlloc(cmsContext ContextID, int nCurves, int nElements, cmsT

c16->Curves[i] = _cmsCalloc(ContextID, nElements, sizeof(cmsUInt16Number));

if (c16->Curves[i] == NULL) {

for (j=0; j < i; j++) {
_cmsFree(ContextID, c16->Curves[j]);
}
_cmsFree(ContextID, c16->Curves);
_cmsFree(ContextID, c16);
return NULL;
}

if (nElements == 256) {

for (j=0; j < nElements; j++) {
Expand Down

0 comments on commit 91c2db7

Please sign in to comment.