< prev index next >


Print this page
@@ -99,11 +99,11 @@
  // Memory handling ------------------------------------------------------------------
  // This is the interface to low-level memory management routines. By default a simple
  // wrapping to malloc/free/realloc is provided, although there is a limit on the max
- // amount of memoy that can be reclaimed. This is mostly as a safety feature to prevent
+ // amount of memory that can be reclaimed. This is mostly as a safety feature to prevent
  // bogus or evil code to allocate huge blocks that otherwise lcms would never need.
  #define MAX_MEMORY_FOR_ALLOC  ((cmsUInt32Number)(1024U*1024U*512U))
  // User may override this behaviour by using a memory plug-in, which basically replaces

@@ -119,11 +119,12 @@
  // This is the default memory allocation function. It does a very coarse
  // check of amount of memory, just to prevent exploits
  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);

@@ -261,11 +262,11 @@
      cmsPluginMemHandler* Plugin = (cmsPluginMemHandler*) Data;
      _cmsMemPluginChunkType* ptr;
      // NULL forces to reset to defaults. In this special case, the defaults are stored in the context structure.
      // Remaining plug-ins does NOT have any copy in the context structure, but this is somehow special as the
-     // context internal data should be malloce'd by using those functions.
+     // context internal data should be malloc'ed by using those functions.
      if (Data == NULL) {
         struct _cmsContext_struct* ctx = ( struct _cmsContext_struct*) ContextID;
         // Return to the default allocators
< prev index next >