Skip to content

Commit 68a1062

Browse files
authored
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; | ^
1 parent b56f068 commit 68a1062

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Zend/zend_alloc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,12 +3465,14 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
34653465
ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void *data, size_t data_size)
34663466
{
34673467
#if ZEND_MM_STORAGE
3468-
zend_mm_storage tmp_storage, *storage;
3468+
zend_mm_storage *storage;
3469+
zend_mm_storage tmp_storage = {
3470+
.handlers = *handlers,
3471+
.data = data,
3472+
};
34693473
zend_mm_chunk *chunk;
34703474
zend_mm_heap *heap;
34713475

3472-
memcpy((zend_mm_handlers*)&tmp_storage.handlers, handlers, sizeof(zend_mm_handlers));
3473-
tmp_storage.data = data;
34743476
chunk = (zend_mm_chunk*)handlers->chunk_alloc(&tmp_storage, ZEND_MM_CHUNK_SIZE, ZEND_MM_CHUNK_SIZE);
34753477
if (UNEXPECTED(chunk == NULL)) {
34763478
#if ZEND_MM_ERROR

0 commit comments

Comments
 (0)