Skip to content

Commit 8765994

Browse files
committed
Improve
1 parent 5da91c2 commit 8765994

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Zend/zend_alloc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,6 @@ static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count ZEND_F
11251125
#else
11261126
zend_mm_safe_error(heap, "Out of memory (allocated %zu bytes) (tried to allocate %zu bytes)", heap->real_size, ZEND_MM_PAGE_SIZE * pages_count);
11271127
#endif
1128-
ZEND_MM_POISON_CHUNK_HDR(chunk, heap);
11291128
return NULL;
11301129
}
11311130
}
@@ -1162,18 +1161,25 @@ static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count ZEND_F
11621161

11631162
found:
11641163
if (steps > 2 && pages_count < 8) {
1164+
ZEND_MM_UNPOISON_CHUNK_HDR(chunk->next);
1165+
ZEND_MM_UNPOISON_CHUNK_HDR(chunk->prev);
11651166
ZEND_MM_CHECK(chunk->next->prev == chunk, "zend_mm_heap corrupted");
11661167
ZEND_MM_CHECK(chunk->prev->next == chunk, "zend_mm_heap corrupted");
11671168

11681169
/* move chunk into the head of the linked-list */
11691170
chunk->prev->next = chunk->next;
11701171
chunk->next->prev = chunk->prev;
1172+
ZEND_MM_POISON_CHUNK_HDR(chunk->next, heap);
1173+
ZEND_MM_POISON_CHUNK_HDR(chunk->prev, heap);
1174+
11711175
ZEND_MM_UNPOISON_CHUNK_HDR(heap->main_chunk);
1176+
ZEND_MM_UNPOISON_CHUNK_HDR(heap->main_chunk->next);
11721177
chunk->next = heap->main_chunk->next;
11731178
chunk->prev = heap->main_chunk;
11741179
chunk->prev->next = chunk;
11751180
chunk->next->prev = chunk;
11761181
ZEND_MM_POISON_CHUNK_HDR(heap->main_chunk, heap);
1182+
ZEND_MM_POISON_CHUNK_HDR(heap->main_chunk->next, heap);
11771183
}
11781184
/* mark run as allocated */
11791185
chunk->free_pages -= pages_count;

0 commit comments

Comments
 (0)