summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-09-03 11:56:55 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-09-03 12:31:23 +0200
commit7620ea15807a84e76cb1cb2f9d5234ea787aae2e (patch)
tree2aa3bbc0ade168c8f07a83eb2b87cbfad194940f /Zend/zend_compile.c
parentc4016ecd446ef26bb3dc77735b6e441e151ea985 (diff)
downloadphp-git-7620ea15807a84e76cb1cb2f9d5234ea787aae2e.tar.gz
Don't intern compiled_filename
For php-ast interning the file name is an effective memory leak, see php-ast#134. I don't think there's any reason to do this. At some point this was needed due to bugs in the interned string mechanism that caused issues if the string was later interned, e.g. through a __FILE__ reference. These issues have since been resolved. In conjunction with the filenames_table removal in c4016ecd446ef26bb3dc77735b6e441e151ea985 this means that filenames now need to be refcounted like normal strings. In particular the filename reference in op_arrays and CEs are refcounted.
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index a60ceb1c84..21db0a3f7d 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -442,14 +442,17 @@ void shutdown_compiler(void) /* {{{ */
ZEND_API zend_string *zend_set_compiled_filename(zend_string *new_compiled_filename) /* {{{ */
{
- new_compiled_filename = zend_new_interned_string(zend_string_copy(new_compiled_filename));
- CG(compiled_filename) = new_compiled_filename;
+ CG(compiled_filename) = zend_string_copy(new_compiled_filename);
return new_compiled_filename;
}
/* }}} */
ZEND_API void zend_restore_compiled_filename(zend_string *original_compiled_filename) /* {{{ */
{
+ if (CG(compiled_filename)) {
+ zend_string_release(CG(compiled_filename));
+ CG(compiled_filename) = NULL;
+ }
CG(compiled_filename) = original_compiled_filename;
}
/* }}} */
@@ -7345,7 +7348,7 @@ void zend_compile_class_decl(znode *result, zend_ast *ast, zend_bool toplevel) /
}
ce->ce_flags |= decl->flags;
- ce->info.user.filename = zend_get_compiled_filename();
+ ce->info.user.filename = zend_string_copy(zend_get_compiled_filename());
ce->info.user.line_start = decl->start_lineno;
ce->info.user.line_end = decl->end_lineno;