[php-src] master: Add two checks for zend_mm_heap's integrity (#13943)

From: Date: Tue, 23 Apr 2024 09:50:31 +0000
Subject: [php-src] master: Add two checks for zend_mm_heap's integrity (#13943)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-128211@lists.php.net to get a copy of this message
Author: Julien Voisin (jvoisin) Committer: GitHub (web-flow) Pusher: arnaud-lb Date: 2024-04-23T11:50:24+02:00 Commit: https://github.com/php/php-src/commit/07337df1d74e2e0dafc89d387653cf52da4604b7 Raw diff: https://github.com/php/php-src/commit/07337df1d74e2e0dafc89d387653cf52da4604b7.diff Add two checks for zend_mm_heap's integrity (#13943) Changed paths: M Zend/zend_alloc.c Diff: diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 09d161e62c16..f92458328de9 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1065,6 +1065,9 @@ static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count ZEND_F found: if (steps > 2 && pages_count < 8) { + ZEND_MM_CHECK(chunk->next->prev == chunk, "zend_mm_heap corrupted"); + ZEND_MM_CHECK(chunk->prev->next == chunk, "zend_mm_heap corrupted"); + /* move chunk into the head of the linked-list */ chunk->prev->next = chunk->next; chunk->next->prev = chunk->prev; @@ -1116,6 +1119,9 @@ static zend_never_inline void *zend_mm_alloc_large(zend_mm_heap *heap, size_t si static zend_always_inline void zend_mm_delete_chunk(zend_mm_heap *heap, zend_mm_chunk *chunk) { + ZEND_MM_CHECK(chunk->next->prev == chunk, "zend_mm_heap corrupted"); + ZEND_MM_CHECK(chunk->prev->next == chunk, "zend_mm_heap corrupted"); + chunk->next->prev = chunk->prev; chunk->prev->next = chunk->next; heap->chunks_count--;

« previous php.cvs (#128211) next »