- Z_STRLEN(tmp) = strlen(fh.filename);
- Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
-@@ -630,13 +659,15 @@
+ ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1));
+ zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp);
+ if (opened_path) {
+ zend_string_release(opened_path);
+- } else {
++ }
++
++ if (fh.filename) {
+ efree((char *)fh.filename);
++ fh.filename = NULL;
+ }
++
+ php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp));
+ }
+ }
+@@ -624,13 +656,15 @@