Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix unspecified behaviour in zend_alloc in heap->limit computation
This commit is contained in:
Niels Dossche 2023-11-06 19:46:57 +01:00
commit 85cb081661

View file

@ -1933,7 +1933,7 @@ static zend_mm_heap *zend_mm_init(void)
heap->peak = 0; heap->peak = 0;
#endif #endif
#if ZEND_MM_LIMIT #if ZEND_MM_LIMIT
heap->limit = ((size_t)Z_L(-1) >> (size_t)Z_L(1)); heap->limit = (size_t)Z_L(-1) >> 1;
heap->overflow = 0; heap->overflow = 0;
#endif #endif
#if ZEND_MM_CUSTOM #if ZEND_MM_CUSTOM
@ -2907,7 +2907,7 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
zend_mm_heap *mm_heap = alloc_globals->mm_heap = malloc(sizeof(zend_mm_heap)); zend_mm_heap *mm_heap = alloc_globals->mm_heap = malloc(sizeof(zend_mm_heap));
memset(mm_heap, 0, sizeof(zend_mm_heap)); memset(mm_heap, 0, sizeof(zend_mm_heap));
mm_heap->use_custom_heap = ZEND_MM_CUSTOM_HEAP_STD; mm_heap->use_custom_heap = ZEND_MM_CUSTOM_HEAP_STD;
mm_heap->limit = ((size_t)Z_L(-1) >> (size_t)Z_L(1)); mm_heap->limit = (size_t)Z_L(-1) >> 1;
mm_heap->overflow = 0; mm_heap->overflow = 0;
if (!tracked) { if (!tracked) {
@ -3096,7 +3096,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
heap->peak = 0; heap->peak = 0;
#endif #endif
#if ZEND_MM_LIMIT #if ZEND_MM_LIMIT
heap->limit = (Z_L(-1) >> Z_L(1)); heap->limit = (size_t)Z_L(-1) >> 1;
heap->overflow = 0; heap->overflow = 0;
#endif #endif
#if ZEND_MM_CUSTOM #if ZEND_MM_CUSTOM