[php-src] master: Merge branch 'PHP-8.6'
| From: | David Carlier | Date: | Wed, 18 Nov 2026 06:14:15 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143821@lists.php.net to get a copy of this message | ||
Author: David Carlier (devnexen)
Date: 2026-11-18T06:13:05Z
Commit: https://github.com/php/php-src/commit/e714eee60dda70e22aef46064312256d2aa8dcf8
Raw diff: https://github.com/php/php-src/commit/e714eee60dda70e22aef46064312256d2aa8dcf8.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
ext/spl: Fix leak of the static variables of a file loaded by spl_autoload()
Changed paths:
A ext/spl/tests/spl_autoload_static_variable_leak.phpt
M ext/spl/php_spl.c
Diff:
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index a3b0bfbe770e..8d516c1543fb 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -290,6 +290,7 @@ static bool spl_autoload(zend_string *lc_name, const char *ext, size_t ext_len)
zend_execute(new_op_array, &result);
EG(jit_trace_num) = orig_jit_trace_num;
+ zend_destroy_static_vars(new_op_array);
destroy_op_array(new_op_array);
efree(new_op_array);
zval_ptr_dtor(&result);
diff --git a/ext/spl/tests/spl_autoload_static_variable_leak.phpt
b/ext/spl/tests/spl_autoload_static_variable_leak.phpt
new file mode 100644
index 000000000000..92e390fcc534
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_static_variable_leak.phpt
@@ -0,0 +1,22 @@
+--TEST--
+spl_autoload() frees the static variables of the autoloaded file
+--INI--
+report_memleaks=1
+--FILE--
+<?php
+$dir = __DIR__ . '/spl_autoload_static_variable_leak_dir';
+mkdir($dir);
+set_include_path($dir);
+file_put_contents($dir . '/stat1.php', '<?php static $top = [1, 2, 3]; class
Stat1 {}');
+
+spl_autoload('Stat1');
+var_dump(class_exists('Stat1', false));
+?>
+--CLEAN--
+<?php
+$dir = __DIR__ . '/spl_autoload_static_variable_leak_dir';
+@unlink($dir . '/stat1.php');
+@rmdir($dir);
+?>
+--EXPECT--
+bool(true)