Skip to content

Commit

Permalink
- null deref fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejoye committed Feb 7, 2011
1 parent 312235c commit a0a603d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ static zend_mm_storage* zend_mm_mem_win32_init(void *params)
return NULL;
}
storage = (zend_mm_storage*)malloc(sizeof(zend_mm_storage));
if (storage == NULL) {
HeapDestroy(heap);
return NULL;
}
storage->data = (void*) heap;
return storage;
}
Expand Down Expand Up @@ -1088,7 +1092,13 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers,
storage->handlers = handlers;

heap = malloc(sizeof(struct _zend_mm_heap));

if (heap == NULL) {
fprintf(stderr, "Cannot allocate heap for zend_mm storage [%s]\n", handlers->name);
#ifdef PHP_WIN32
fflush(stderr);
#endif
exit(255);
}
heap->storage = storage;
heap->block_size = block_size;
heap->compact_size = 0;
Expand Down

0 comments on commit a0a603d

Please sign in to comment.