Commit c82acefe470 for php.net
commit c82acefe470e0444540c63d2329d8cc675d5777c
Author: Gina Peter Banyard <girgias@php.net>
Date: Sun Jul 19 18:16:22 2026 +0100
main: convert unserialize_callback_func global to zend_string*
This prevents a reallocation
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index a9f1f96f366..458ad2f12ba 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -1249,14 +1249,14 @@ object ":" uiv ":" ["] {
}
/* Check for unserialize callback */
- if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) {
+ if (PG(unserialize_callback_func) == NULL) {
incomplete_class = 1;
ce = PHP_IC_ENTRY;
break;
}
/* Call unserialize callback */
- ZVAL_STRING(&user_func, PG(unserialize_callback_func));
+ ZVAL_STR_COPY(&user_func, PG(unserialize_callback_func));
ZVAL_STR(&args[0], class_name);
BG(serialize_lock)++;
diff --git a/main/main.c b/main/main.c
index 0a1d6735864..48cdc4e05d3 100644
--- a/main/main.c
+++ b/main/main.c
@@ -823,7 +823,7 @@ PHP_INI_BEGIN()
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)
- STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateString, unserialize_callback_func, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateStrNotEmpty, unserialize_callback_func, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("serialize_precision", "-1", PHP_INI_ALL, OnSetSerializePrecision, serialize_precision, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("arg_separator.output", "&", PHP_INI_ALL, OnUpdateStrNotEmpty, arg_separator.output, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("arg_separator.input", "&", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateStrNotEmpty, arg_separator.input, php_core_globals, core_globals)
diff --git a/main/php_globals.h b/main/php_globals.h
index 0bab9fc95c1..537e1cfd2dc 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -67,7 +67,7 @@ struct _php_core_globals {
char *output_handler;
- char *unserialize_callback_func;
+ zend_string *unserialize_callback_func;
zend_long serialize_precision;
zend_long memory_limit;