Skip to content

Commit

Permalink
Merge pull request #407 from x2018/_cmsMallocDefaultFn
Browse files Browse the repository at this point in the history
Not allow 0 as the size for memory allocation
Looks great, thanks you!
  • Loading branch information
mm2 authored Oct 31, 2023
2 parents 5c0655a + 71e58f1 commit bbd6f1b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cmserr.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plug
static
void* _cmsMallocDefaultFn(cmsContext ContextID, cmsUInt32Number size)
{
if (size > MAX_MEMORY_FOR_ALLOC) return NULL; // Never allow over maximum
// Never allow 0 or over maximum
if (size == 0 || size > MAX_MEMORY_FOR_ALLOC) return NULL;

return (void*) malloc(size);

Expand Down

0 comments on commit bbd6f1b

Please sign in to comment.