[php-src] PR #21624: Fix GH-19200: replace unchecked realloc/malloc with perealloc/pemalloc

From: Date: Fri, 03 Apr 2026 15:52:25 +0000
Subject: [php-src] PR #21624: Fix GH-19200: replace unchecked realloc/malloc with perealloc/pemalloc
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-35501@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/21624 Author: iliaal ## Summary Several call sites use raw realloc()/malloc() without checking for NULL. When realloc() fails, it returns NULL and the original pointer is lost, crashing on the next dereference. Replaced with perealloc()/pemalloc() (persistent=1), which wrap the system allocator and call zend_out_of_memory() on failure for a clean exit. Changes: - Zend/zend.c, zend_append_version_info() realloc - Zend/zend_API.c, zend_collect_module_handlers() (3 reallocs), zend_register_functions() (2 reallocs + 3 mallocs), do_register_internal_class() (1 malloc) - Zend/zend_inheritance.c, ce->interfaces realloc in 2 ZEND_INTERNAL_CLASS branches, simplified to single perealloc() matching the pattern at zend_implement_stringable() - ext/opcache/zend_accelerator_blacklist.c, blacklist entries realloc - main/network.c, gethostname_re() variants (3 mallocs + 3 reallocs) - main/php_ini.c, php_ini_scanned_files realloc - main/php_ini_builder.h, INI builder realloc - sapi/phpdbg/phpdbg.c, extension list realloc/malloc - sapi/phpdbg/phpdbg_prompt.c, code buffer realloc/malloc Skipped zend_alloc.c (already handles this) and IR JIT code (third-party). Fixes GH-19200, closes GH-17013

« previous php.git-pulls (#35501) next »