From: Dmitry Stogov Date: Mon, 12 Mar 2007 16:59:52 +0000 (+0000) Subject: Fixed bug #40770 (Apache child exits when PHP memory limit reached) X-Git-Tag: php-5.2.2RC1~166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab699d03bc841f14718b4563bd50288168473640;p=php Fixed bug #40770 (Apache child exits when PHP memory limit reached) --- diff --git a/NEWS b/NEWS index 998b827aef..26f998b925 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ PHP NEWS - Fixed a thread safety issue in gd gif read code (Nuno, Roman Nemecek) - Fixed CVE-2007-1001, GD wbmp used with invalid image size (Pierre) - Fixed bug #40784 (Case sensivity in constructor's fallback). (Tony) +- Fixed bug #40770 (Apache child exits when PHP memory limit reached). (Dmitry) - Fixed bug #40764 (line thickness not respected for horizontal and vertical lines). (Pierre) - Fixed bug #40754 (added substr() & substr_replace() overflow checks). (Ilia) diff --git a/Zend/tests/bug40770.phpt b/Zend/tests/bug40770.phpt new file mode 100755 index 0000000000..fd01303f7f --- /dev/null +++ b/Zend/tests/bug40770.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #40770 Apache child exits when PHP memory limit reached +--INI-- +memory_limit=64M +--FILE-- + +--EXPECTF-- +Fatal error: Allowed memory size of 67108864 bytes exhausted%s(tried to allocate %d bytes) in %sbug40770.php on line 6 diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 736b6303e2..34f5b77b60 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1714,6 +1714,9 @@ realloc_segment: segment_copy = (zend_mm_segment *) ((char *)mm_block - ZEND_MM_ALIGNED_SEGMENT_SIZE); if (segment_size < true_size || heap->real_size + segment_size - segment_copy->size > heap->limit) { + if (ZEND_MM_IS_FREE_BLOCK(next_block)) { + zend_mm_add_to_free_list(heap, (zend_mm_free_block *) next_block); + } #if ZEND_MM_CACHE zend_mm_free_cache(heap); #endif