@@ -836,10 +836,13 @@ - (void*)allocMemoryWithSize: (size_t)size { void *pointer; struct pre_mem *preMem; + + if OF_UNLIKELY (size == 0) + return NULL; if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; if OF_UNLIKELY ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL) @@ -862,13 +865,10 @@ } - (void*)allocMemoryWithSize: (size_t)size count: (size_t)count { - if OF_UNLIKELY (size == 0 || count == 0) - return NULL; - if OF_UNLIKELY (count > SIZE_MAX / size) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; return [self allocMemoryWithSize: size * count]; }