summaryrefslogtreecommitdiff
path: root/Zend/zend_alloc.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-07-09 11:03:56 +0000
committerZeev Suraski <zeev@php.net>1999-07-09 11:03:56 +0000
commit6abe9c34d9be62d62a2841635fd733802f15e83c (patch)
tree368c68343eeab97817c2ed0b35f1c5a6cc35fbf4 /Zend/zend_alloc.c
parent81f552221053bbcd0f2cd31d0aac8abdf99e1ddc (diff)
downloadphp-git-6abe9c34d9be62d62a2841635fd733802f15e83c.tar.gz
* Support recoverable failure from erealloc()
* Fix the shutdown code on an unrecoverable erealloc() failure
Diffstat (limited to 'Zend/zend_alloc.c')
-rw-r--r--Zend/zend_alloc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 576356420c..740b424f95 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -200,9 +200,9 @@ ZEND_API void *_ecalloc(size_t nmemb, size_t size)
#if ZEND_DEBUG
-ZEND_API void *_erealloc(void *ptr, size_t size, char *filename, uint lineno)
+ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure, char *filename, uint lineno)
#else
-ZEND_API void *_erealloc(void *ptr, size_t size)
+ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure)
#endif
{
mem_header *p = (mem_header *) ((char *)ptr-sizeof(mem_header)-PLATFORM_PADDING);
@@ -220,10 +220,12 @@ ZEND_API void *_erealloc(void *ptr, size_t size)
REMOVE_POINTER_FROM_LIST(p);
p = (mem_header *) realloc(p,sizeof(mem_header)+size+PLATFORM_PADDING+END_ALIGNMENT(size)+END_MAGIC_SIZE);
if (!p) {
- fprintf(stderr,"FATAL: erealloc(): Unable to allocate %ld bytes\n", (long) size);
- HANDLE_UNBLOCK_INTERRUPTIONS();
- zend_bailout();
+ if (!allow_failure) {
+ fprintf(stderr,"FATAL: erealloc(): Unable to allocate %ld bytes\n", (long) size);
+ exit(1);
+ }
ADD_POINTER_TO_LIST(orig);
+ HANDLE_UNBLOCK_INTERRUPTIONS();
return (void *)NULL;
}
ADD_POINTER_TO_LIST(p);