1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix -Wdefault-const-init-field-unsafe with clang 21 (#21135)

Fixes the following warning:

Zend/zend_alloc.c:3469:18: error: default initialization of an object of type 'zend_mm_storage' (aka 'struct _zend_mm_storage') with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
 3469 |         zend_mm_storage tmp_storage, *storage;
      |                         ^
Zend/zend_alloc.h:313:25: note: member 'handlers' declared 'const' here
  313 |         const zend_mm_handlers handlers;
      |                                ^
This commit is contained in:
Arnaud Le Blanc
2026-02-05 14:30:58 +01:00
committed by GitHub
parent b56f068756
commit 68a10628a2

View File

@@ -3465,12 +3465,14 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size) ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size)
{ {
#if ZEND_MM_STORAGE #if ZEND_MM_STORAGE
zend_mm_storage tmp_storage, *storage; zend_mm_storage *storage;
zend_mm_storage tmp_storage = {
.handlers = *handlers,
.data = data,
};
zend_mm_chunk *chunk; zend_mm_chunk *chunk;
zend_mm_heap *heap; zend_mm_heap *heap;
memcpy((zend_mm_handlers*)&tmp_storage.handlers, handlers, sizeof(zend_mm_handlers));
tmp_storage.data = data;
chunk = (zend_mm_chunk*)handlers->chunk_alloc(&tmp_storage, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE); chunk = (zend_mm_chunk*)handlers->chunk_alloc(&tmp_storage, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE);
if (UNEXPECTED(chunk == NULL)) { if (UNEXPECTED(chunk == NULL)) {
#if ZEND_MM_ERROR #if ZEND_MM_ERROR