Fixed compiler reenterability
authorDmitry Stogov <dmitry@zend.com>
Wed, 14 Nov 2012 13:45:10 +0000 (17:45 +0400)
committerDmitry Stogov <dmitry@zend.com>
Wed, 14 Nov 2012 13:45:10 +0000 (17:45 +0400)
Zend/zend_compile.c
Zend/zend_language_scanner.l

index 4dd3eaf1ed2e1b7e629260a5f794aa4c1849294a..f25e7fac6d2d9ee746ec5cebe818662132dea7ba 100644 (file)
@@ -219,6 +219,7 @@ ZEND_API void file_handle_dtor(zend_file_handle *fh) /* {{{ */
 void init_compiler(TSRMLS_D) /* {{{ */
 {
        CG(active_op_array) = NULL;
+       memset(&CG(context), 0, sizeof(CG(context)));
        zend_init_compiler_data_structures(TSRMLS_C);
        zend_init_rsrc_list(TSRMLS_C);
        zend_hash_init(&CG(filenames_table), 5, NULL, (dtor_func_t) free_estring, 0);
index 703ca968ea6cf13b456e88d1ee00c61d9617d9a2..bb35a9339c2f5bf12446ee3bf1170708f3da7f89 100644 (file)
@@ -578,6 +578,7 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSR
                init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);
                CG(in_compilation) = 1;
                CG(active_op_array) = op_array;
+               zend_stack_push(&CG(context_stack), (void *) &CG(context), sizeof(CG(context)));
                zend_init_compiler_context(TSRMLS_C);
                compiler_result = zendparse(TSRMLS_C);
                zend_do_return(&retval_znode, 0 TSRMLS_CC);
@@ -747,6 +748,7 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
                init_op_array(op_array, ZEND_EVAL_CODE, INITIAL_OP_ARRAY_SIZE TSRMLS_CC);
                CG(interactive) = orig_interactive;
                CG(active_op_array) = op_array;
+               zend_stack_push(&CG(context_stack), (void *) &CG(context), sizeof(CG(context)));
                zend_init_compiler_context(TSRMLS_C);
                BEGIN(ST_IN_SCRIPTING);
                compiler_result = zendparse(TSRMLS_C);