Skip to content

Commit

Permalink
sync lcms2 bug-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
issakomi committed Aug 11, 2022
1 parent 3f20599 commit 702b7f1
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions alizalcms/cmscgats.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ static
string* StringAlloc(cmsIT8* it8, int max)
{
string* s = (string*) AllocChunk(it8, sizeof(string));
if (s == NULL) return NULL;

s->it8 = it8;
s->max = max;
Expand All @@ -391,7 +392,9 @@ void StringAppend(string* s, char c)

s->max *= 10;
new_ptr = (char*) AllocChunk(s->it8, s->max);
memcpy(new_ptr, s->begin, s->len);
if (new_ptr != NULL)
memcpy(new_ptr, s->begin, s->len);

s->begin = new_ptr;
}

Expand Down Expand Up @@ -992,8 +995,10 @@ void InSymbol(cmsIT8* it8)
if(FileNest == NULL) {

FileNest = it8 ->FileStack[it8 -> IncludeSP + 1] = (FILECTX*)AllocChunk(it8, sizeof(FILECTX));
//if(FileNest == NULL)
// TODO: how to manage out-of-memory conditions?
if (FileNest == NULL) {
SynError(it8, "Out of memory");
return;
}
}

if (BuildAbsolutePath(StringPtr(it8->str),
Expand Down Expand Up @@ -1167,9 +1172,11 @@ void* AllocChunk(cmsIT8* it8, cmsUInt32Number size)
it8 ->Allocator.BlockSize = size;

it8 ->Allocator.Used = 0;
it8 ->Allocator.Block = (cmsUInt8Number*) AllocBigBlock(it8, it8 ->Allocator.BlockSize);
it8 ->Allocator.Block = (cmsUInt8Number*) AllocBigBlock(it8, it8 ->Allocator.BlockSize);
}

if (it8->Allocator.Block == NULL) return NULL;

ptr = it8 ->Allocator.Block + it8 ->Allocator.Used;
it8 ->Allocator.Used += size;

Expand Down Expand Up @@ -2535,15 +2542,18 @@ cmsUInt32Number CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyN
}


Props = (char **) AllocChunk(it8, sizeof(char *) * n);
Props = (char**)AllocChunk(it8, sizeof(char*) * n);
if (Props != NULL) {

// Pass#2 - Fill pointers
n = 0;
for (p = t -> HeaderList; p != NULL; p = p->Next) {
Props[n++] = p -> Keyword;
}
// Pass#2 - Fill pointers
n = 0;
for (p = t->HeaderList; p != NULL; p = p->Next) {
Props[n++] = p->Keyword;
}

}
*PropertyNames = Props;

*PropertyNames = Props;
return n;
}

Expand Down Expand Up @@ -2575,12 +2585,14 @@ cmsUInt32Number CMSEXPORT cmsIT8EnumPropertyMulti(cmsHANDLE hIT8, const char* cP


Props = (const char **) AllocChunk(it8, sizeof(char *) * n);
if (Props != NULL) {

// Pass#2 - Fill pointers
n = 0;
for (tmp = p; tmp != NULL; tmp = tmp->NextSubkey) {
if(tmp->Subkey != NULL)
Props[n++] = p ->Subkey;
// Pass#2 - Fill pointers
n = 0;
for (tmp = p; tmp != NULL; tmp = tmp->NextSubkey) {
if (tmp->Subkey != NULL)
Props[n++] = p->Subkey;
}
}

*SubpropertyNames = Props;
Expand Down

0 comments on commit 702b7f1

Please sign in to comment.