From 7b63e56aa249e64dd6ea37bc66fe6c006715fbd3 Mon Sep 17 00:00:00 2001 From: xinhaiz Date: Mon, 23 Mar 2020 23:29:37 +0800 Subject: [PATCH 1/2] fix symbol_table op --- views/yaf_view_simple.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/views/yaf_view_simple.c b/views/yaf_view_simple.c index ce8944e2..f3d4f612 100644 --- a/views/yaf_view_simple.c +++ b/views/yaf_view_simple.c @@ -99,17 +99,15 @@ static int yaf_view_simple_valid_var_name(char *var_name, int len) /* {{{ */ static zend_array *yaf_view_build_symtable(zval *tpl_vars, zval *vars) /* {{{ */ { zval *entry; zend_string *var_name; - zend_array *symbol_table; + HashTable *symbol_table; #if PHP_VERSION_ID < 70100 zend_class_entry *scope = EG(scope); #else zend_class_entry *scope = zend_get_executed_scope(); #endif - symbol_table = emalloc(sizeof(zend_array)); - + ALLOC_HASHTABLE(symbol_table); zend_hash_init(symbol_table, 8, NULL, ZVAL_PTR_DTOR, 0); - zend_hash_real_init(symbol_table, 0); if (tpl_vars && Z_TYPE_P(tpl_vars) == IS_ARRAY) { ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(tpl_vars), var_name, entry) { @@ -142,7 +140,7 @@ static zend_array *yaf_view_build_symtable(zval *tpl_vars, zval *vars) /* {{{ */ } if (yaf_view_simple_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { - if (EXPECTED(zend_hash_add_new(symbol_table, var_name, entry))) { + if (EXPECTED(zend_hash_update(symbol_table, var_name, entry))) { Z_TRY_ADDREF_P(entry); } } From 68b9558b7886d90e6fc7979e53692828216c4169 Mon Sep 17 00:00:00 2001 From: xinhaiz Date: Tue, 24 Mar 2020 09:53:05 +0800 Subject: [PATCH 2/2] Add test for PR468 --- tests/pr468.phpt | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/pr468.phpt diff --git a/tests/pr468.phpt b/tests/pr468.phpt new file mode 100644 index 00000000..1f5ef866 --- /dev/null +++ b/tests/pr468.phpt @@ -0,0 +1,67 @@ +--TEST-- +PR #468 Check for sysboml table bug +--SKIPIF-- + +--INI-- +yaf.use_spl_autoload=0 +yaf.use_namespace=0 + +--FILE-- + array( + "directory" => APPLICATION_PATH, + "dispatcher" => array ( + "catchException" => true, + ), + "library" => array( + ), + ), +); + +file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<getConfig()); + } + } +PHP +); + + +$value = NULL; + +file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<getView()->assign("ref", "ref-source"); + \$this->getView()->display("index/index.phtml", ["ref" => "ref-changed"]); + return false; + } + } +PHP +); + +file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", ""); + +$app = new Yaf_Application($config); +$app->bootstrap()->run(); + +?> +--CLEAN-- + +--EXPECTF-- +string(11) "ref-changed" +