Skip to content

Commit 07337df

Browse files
authored
Add two checks for zend_mm_heap's integrity (#13943)
1 parent bffab33 commit 07337df

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/zend_alloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,9 @@ static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count ZEND_F
10651065

10661066
found:
10671067
if (steps > 2 && pages_count < 8) {
1068+
ZEND_MM_CHECK(chunk->next->prev == chunk, "zend_mm_heap corrupted");
1069+
ZEND_MM_CHECK(chunk->prev->next == chunk, "zend_mm_heap corrupted");
1070+
10681071
/* move chunk into the head of the linked-list */
10691072
chunk->prev->next = chunk->next;
10701073
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
11161119

11171120
static zend_always_inline void zend_mm_delete_chunk(zend_mm_heap *heap, zend_mm_chunk *chunk)
11181121
{
1122+
ZEND_MM_CHECK(chunk->next->prev == chunk, "zend_mm_heap corrupted");
1123+
ZEND_MM_CHECK(chunk->prev->next == chunk, "zend_mm_heap corrupted");
1124+
11191125
chunk->next->prev = chunk->prev;
11201126
chunk->prev->next = chunk->next;
11211127
heap->chunks_count--;

0 commit comments

Comments
 (0)