Skip to content

Commit

Permalink
Add more checks for crafted CGATS
Browse files Browse the repository at this point in the history
Improve non-happy path
  • Loading branch information
mm2 committed Apr 20, 2024
1 parent 83f650b commit c646a72
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/cmscgats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,8 @@ void* AllocChunk(cmsIT8* it8, cmsUInt32Number size)

if (size > Free) {

cmsUInt8Number* new_block;

if (it8 -> Allocator.BlockSize == 0)

it8 -> Allocator.BlockSize = 20*1024;
Expand All @@ -1220,7 +1222,11 @@ void* AllocChunk(cmsIT8* it8, cmsUInt32Number size)
it8 ->Allocator.BlockSize = size;

it8 ->Allocator.Used = 0;
it8 ->Allocator.Block = (cmsUInt8Number*) AllocBigBlock(it8, it8 ->Allocator.BlockSize);
new_block = (cmsUInt8Number*)AllocBigBlock(it8, it8->Allocator.BlockSize);
if (new_block == NULL)
return NULL;

it8->Allocator.Block = new_block;
}

if (it8->Allocator.Block == NULL)
Expand All @@ -1230,7 +1236,6 @@ void* AllocChunk(cmsIT8* it8, cmsUInt32Number size)
it8 ->Allocator.Used += size;

return (void*) ptr;

}


Expand Down Expand Up @@ -1732,7 +1737,10 @@ char* GetData(cmsIT8* it8, int nSet, int nField)
static
cmsBool SetData(cmsIT8* it8, int nSet, int nField, const char *Val)
{
char* ptr;

TABLE* t = GetTable(it8);


if (!t->Data) {
if (!AllocateDataSet(it8)) return FALSE;
Expand All @@ -1750,7 +1758,11 @@ cmsBool SetData(cmsIT8* it8, int nSet, int nField, const char *Val)

}

t->Data [nSet * t -> nSamples + nField] = AllocString(it8, Val);
ptr = AllocString(it8, Val);
if (ptr == NULL)
return FALSE;

t->Data [nSet * t -> nSamples + nField] = ptr;
return TRUE;
}

Expand Down

0 comments on commit c646a72

Please sign in to comment.