Ok, I worked out a patch which does not leak memory. I don't think thread-safety is an issue here but if anyone with deeper insight into Zend sees any problem with this patch, please tell me.

What's the process (and chance :-)) of having this included in a future version of PHP? Should I also look into making a PHP5/Zend2 version of it?

Comments welcome,
- Chris
Index: Zend/zend_builtin_functions.c
===================================================================
RCS file: /repository/Zend/Attic/zend_builtin_functions.c,v
retrieving revision 1.124.2.9
diff -u -r1.124.2.9 zend_builtin_functions.c
--- Zend/zend_builtin_functions.c       16 Jun 2003 15:55:07 -0000      1.124.2.9
+++ Zend/zend_builtin_functions.c       26 Oct 2003 11:49:15 -0000
@@ -1186,6 +1186,8 @@
        char *call_type;
        char *include_filename = NULL;
        zval *stack_frame;
+       zval *vars;
+       zval *tmp;
        void **cur_arg_pos = EG(argument_stack).top_element;
        void **args = cur_arg_pos;
        int arg_stack_consistent = 0;
@@ -1232,6 +1234,13 @@
                         * want to pop anything of the argument-stack */
                } else {
                        filename = NULL;
+               }
+
+               if (ptr->function_state.function_symbol_table) {
+                       MAKE_STD_ZVAL(vars);
+                       array_init(vars);
+                       zend_hash_copy(vars->value.ht, 
ptr->function_state.function_symbol_table, (copy_ctor_func_t) zval_add_ref, (void *) 
&tmp, sizeof(zval *));
+                       add_assoc_zval_ex(stack_frame, "vars", sizeof("vars"), vars);
                }
 
                function_name = ptr->function_state.function->type != 
ZEND_OVERLOADED_FUNCTION ? ptr->function_state.function->common.function_name : 
get_active_function_name(TSRMLS_C);  /* "OVERLOADED_FUNCTION" */

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to