diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 6bcf5b6cda38..fdb01b3f08db 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -262,6 +262,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha 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); if (!EG(exception)) { 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-- + +--CLEAN-- + +--EXPECT-- +bool(true)