projects/aports·blob master · refs

85 lines · 2.9 KiB

1Patch-Source: https://github.com/igbinary/igbinary/pull/419
2--
3From d4a6ded9ca6b3d7eec069de1891d03c5bc14c233 Mon Sep 17 00:00:00 2001
4From: Andy Postnikov <[email protected]>
5Date: Wed, 12 Aug 2026 03:27:27 +0200
6Subject: [PATCH] Fix build with PHP 8.6: unserialize_callback_func is a
7 zend_string
8
9php-src commit c82acefe470 (php 8.6.0beta1) converted the
10PG(unserialize_callback_func) global from char* to zend_string*.
11
12Fixes #418
13---
14 src/php7/igbinary.c | 19 +++++++++++++++++--
15 1 file changed, 17 insertions(+), 2 deletions(-)
16
17diff --git a/src/php7/igbinary.c b/src/php7/igbinary.c
18index 04048c6..9c2d77c 100644
19--- a/src/php7/igbinary.c
20+++ b/src/php7/igbinary.c
21@@ -3171,7 +3171,11 @@ zend_always_inline static int igbinary_unserialize_object(struct igbinary_unseri
22 zval user_func;
23 zval retval;
24 zval args[1];
25+#if PHP_VERSION_ID >= 80600
26+ zend_string *user_func_name;
27+#else
28 const char* user_func_name;
29+#endif
30
31 /* Try to find class directly */
32 if (EXPECTED((ce = zend_lookup_class(class_name)) != NULL)) {
33@@ -3181,14 +3185,22 @@ zend_always_inline static int igbinary_unserialize_object(struct igbinary_unseri
34
35 user_func_name = PG(unserialize_callback_func);
36 /* Check for unserialize callback */
37+#if PHP_VERSION_ID >= 80600
38+ if ((user_func_name == NULL) || (ZSTR_LEN(user_func_name) == 0)) {
39+#else
40 if ((user_func_name == NULL) || (user_func_name[0] == '\0')) {
41+#endif
42 incomplete_class = 1;
43 ce = PHP_IC_ENTRY;
44 break;
45 }
46
47 /* Call unserialize callback */
48+#if PHP_VERSION_ID >= 80600
49+ ZVAL_STR(&user_func, zend_string_dup(user_func_name, false));
50+#else
51 ZVAL_STRING(&user_func, user_func_name);
52+#endif
53 ZVAL_STR(&args[0], class_name);
54 if (call_user_function(CG(function_table), NULL, &user_func, &retval, 1, args) != SUCCESS) {
55 php_error_docref(NULL, E_WARNING, "defined (%s) but not found", Z_STRVAL(user_func));
56@@ -3199,21 +3211,24 @@ zend_always_inline static int igbinary_unserialize_object(struct igbinary_unseri
57 }
58 /* FIXME: always safe? */
59 zval_ptr_dtor(&retval);
60- zval_ptr_dtor_str(&user_func);
61
62 /* User function call may have raised an exception */
63 if (EG(exception)) {
64 zend_string_release_ex(class_name, 0);
65+ zval_ptr_dtor_str(&user_func);
66 return 1;
67 }
68
69 /* The callback function may have defined the class */
70 ce = zend_lookup_class(class_name);
71 if (!ce) {
72- php_error_docref(NULL, E_WARNING, "Function %s() hasn't defined the class it was called for", PG(unserialize_callback_func));
73+ /* Keep using our own copy of the name: the callback may have
74+ * changed unserialize_callback_func, releasing the ini string */
75+ php_error_docref(NULL, E_WARNING, "Function %s() hasn't defined the class it was called for", Z_STRVAL(user_func));
76 incomplete_class = true;
77 ce = PHP_IC_ENTRY;
78 }
79+ zval_ptr_dtor_str(&user_func);
80 } while (0);
81
82 if (IGBINARY_IS_NOT_UNSERIALIZABLE(ce)) {
83--
842.53.0
85