Hello Johannes,

Friday, February 18, 2005, 2:17:12 PM, you wrote:

JS> this patch doesn't just check wether the string has the right syntax but
JS> also compiles it and registers it's functions and classes in the relevant
JS> tables.
        well, they need to add this code to avoid it:

        n_old_func = zend_hash_num_elements(CG(function_table));
        n_old_class = zend_hash_num_elements(CG(class_table));
        /* actual compile code */
        op_array = ...
        /* free opcode array */
#ifdef ZEND_ENGINE_2
        destroy_op_array(op_array TSRMLS_CC);
#else
        destroy_op_array(op_array);
#endif
        efree(op_array);
        /* clean-up created functions */
        i = 0;
        zend_hash_internal_pointer_reset_ex(CG(function_table), &pos);
        while (zend_hash_get_current_data_ex(CG(function_table), (void **)&zf, 
&pos) == SUCCESS)
        {
                i++;
                if (i > n_old_func && zf->type == ZEND_USER_FUNCTION) {
                        zend_hash_del(CG(function_table), pos->arKey, 
pos->nKeyLength);
                }
                zend_hash_move_forward_ex(CG(function_table), &pos);
        }
        /* clean-up created classes */
        i = 0;
        zend_hash_internal_pointer_reset_ex(CG(class_table), &pos);
        while (zend_hash_get_current_data_ex(CG(class_table), (void **)&zc, 
&pos) == SUCCESS)
        {
#ifdef ZEND_ENGINE_2
                zc = *((zend_class_entry**)zc);
#endif
                i++;
                if (i > n_old_class && zc->type == ZEND_USER_CLASS) {
                        zend_hash_del(CG(class_table), pos->arKey, 
pos->nKeyLength);
                }
                zend_hash_move_forward_ex(CG(class_table), &pos);
        }


-- 
Best regards,
 val                            mailto:[EMAIL PROTECTED]

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

Reply via email to