Commit e0221be81e3 for php.net
commit e0221be81e39860e83867fadd67115e1d2c992c1
Author: Gina Peter Banyard <girgias@php.net>
Date: Sun Jul 19 18:14:44 2026 +0100
main: convert output_handler global to zend_string*
This prevents a reallocation
diff --git a/main/main.c b/main/main.c
index 7c5f8baae30..4fa34258b98 100644
--- a/main/main.c
+++ b/main/main.c
@@ -819,7 +819,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("report_memleaks", "1", PHP_INI_ALL, OnUpdateReportMemleaks, report_memleaks, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("report_zend_debug", "0", PHP_INI_ALL, OnUpdateBool, report_zend_debug, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLong, output_buffering, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateString, output_handler, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateStrNotEmpty, output_handler, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_argc_argv", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("short_open_tag", DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals)
@@ -1886,10 +1886,10 @@ zend_result php_request_startup(void)
sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
}
- if (PG(output_handler) && PG(output_handler)[0]) {
+ if (PG(output_handler)) {
zval oh;
- ZVAL_STRING(&oh, PG(output_handler));
+ ZVAL_STR_COPY(&oh, PG(output_handler));
php_output_start_user(&oh, 0, PHP_OUTPUT_HANDLER_STDFLAGS);
zval_ptr_dtor(&oh);
} else if (PG(output_buffering)) {
diff --git a/main/php_globals.h b/main/php_globals.h
index 45a1b0e44bf..e3cfe38a63f 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -65,7 +65,7 @@ struct _php_core_globals {
bool ignore_repeated_source;
bool report_memleaks;
- char *output_handler;
+ zend_string *output_handler;
zend_string *unserialize_callback_func;
zend_long serialize_precision;