From 7c2a22a96220898b5cc84e16d9fa80ce345d2f6b Mon Sep 17 00:00:00 2001 From: xinhaiz Date: Mon, 23 Oct 2023 23:11:03 +0800 Subject: [PATCH 1/3] openfile destroy --- configs/yaf_config_ini.c | 7 +++++-- tests/110.phpt | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/110.phpt diff --git a/configs/yaf_config_ini.c b/configs/yaf_config_ini.c index 8e87fa87..d65996ff 100644 --- a/configs/yaf_config_ini.c +++ b/configs/yaf_config_ini.c @@ -81,7 +81,7 @@ static zval* yaf_config_ini_get(yaf_config_object *conf, zend_string *name) /* { char *seg, *delim; size_t len; HashTable *target; - + if (conf->config == NULL) { return NULL; } @@ -298,7 +298,7 @@ static void yaf_config_ini_parser_cb(zval *key, zval *value, zval *index, int ca YAF_CONFIG_PARSER_FLAG() = YAF_CONFIG_INI_PARSING_END; return; } - + p = Z_STRVAL_P(key); l = Z_STRLEN_P(key); @@ -387,6 +387,9 @@ int yaf_config_ini_init(yaf_config_object *conf, zval *filename, zend_string *se return 0; } } + + // done + zend_destroy_file_handle(&fh); } else { yaf_trigger_error(E_ERROR, "Argument is not a valid ini file '%s'", ini_file); return 0; diff --git a/tests/110.phpt b/tests/110.phpt new file mode 100644 index 00000000..45d650af --- /dev/null +++ b/tests/110.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug (mem leak or crash in Yaf_Config_Ini, PHP 8.1 or later) +--SKIPIF-- + +--INI-- +yaf.use_spl_autoload=0 +yaf.lowcase_path=0 +yaf.use_namespace=0 +--FILE-- + +--EXPECTF-- +string(4) "Done" \ No newline at end of file From cff7276208c7752e11bf971ddbca92b0105a0646 Mon Sep 17 00:00:00 2001 From: xinhaiz Date: Mon, 23 Oct 2023 23:48:45 +0800 Subject: [PATCH 2/3] openfile destroy --- tests/110.phpt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/110.phpt b/tests/110.phpt index 45d650af..24038f47 100644 --- a/tests/110.phpt +++ b/tests/110.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug (mem leak or crash in Yaf_Config_Ini, PHP 8.1 or later) +Bug (open file not destroy or crash in Yaf_Config_Ini, PHP 8.1 or later) --SKIPIF-- --INI-- @@ -10,7 +10,9 @@ yaf.use_namespace=0 Date: Mon, 23 Oct 2023 23:58:36 +0800 Subject: [PATCH 3/3] update, test modify --- tests/110.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/110.phpt b/tests/110.phpt index 24038f47..f962db60 100644 --- a/tests/110.phpt +++ b/tests/110.phpt @@ -13,7 +13,7 @@ $file = dirname(__FILE__) . "/simple.ini"; // ulimit -n, default 256 // open files will be 257 for ($i = 0; $i < 257; $i++) { - $a = new Yaf\Config\Ini($file); + $a = new Yaf_Config_Ini($file); unset($a); }