[php-src] master: main: convert unserialize_callback_func global to zend_string*
Gina Peter Banyard <[email protected]> Thu, 30 Jul 2026 08:46:01 +0000
| Newsgroups | gmane.comp.php.cvs.general |
|---|---|
| Message-ID | <[email protected]> |
Author: Gina Peter Banyard (Girgias)
Date: 2026-07-30T09:45:57+01:00
Commit: https://github.com/php/php-src/commit/c82acefe470e0444540c63d2329d8cc675d5777c
Raw diff: https://github.com/php/php-src/commit/c82acefe470e0444540c63d2329d8cc675d5777c.diff
main: convert unserialize_callback_func global to zend_string*
This prevents a reallocation
Changed paths:
M ext/standard/var_unserializer.re
M main/main.c
M main/php_globals.h
Diff:
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index a9f1f96f366f..458ad2f12baa 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 0a1d67358649..48cdc4e05d37 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 0bab9fc95c14..537e1cfd2dc7 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;