diff options
author | Juan Linietsky <juan@godotengine.org> | 2019-02-24 10:45:08 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2019-02-24 10:48:38 -0300 |
commit | 3ea04c1366eb83327b4552a8e84b68a8130f6bc1 (patch) | |
tree | eb5dce4d670a368a0bcbac12aa5d7805cf84ab45 /scene/resources/resource_format_text.cpp | |
parent | 755c69025295291d3a361e336f9289edb6634f4d (diff) | |
download | redot-engine-3ea04c1366eb83327b4552a8e84b68a8130f6bc1.tar.gz |
Prevent circular references to scene being saved, fixes #24384
Diffstat (limited to 'scene/resources/resource_format_text.cpp')
-rw-r--r-- | scene/resources/resource_format_text.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 9ef6b9b474..44899bf9fc 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1361,7 +1361,9 @@ String ResourceFormatSaverTextInstance::_write_resource(const RES &res) { if (internal_resources.has(res)) { return "SubResource( " + itos(internal_resources[res]) + " )"; } else if (res->get_path().length() && res->get_path().find("::") == -1) { - + if (res->get_path() == local_path) { //circular reference attempt + return "null"; + } //external resource String path = relative_paths ? local_path.path_to_file(res->get_path()) : res->get_path(); return "Resource( \"" + path + "\" )"; @@ -1386,6 +1388,10 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, return; if (!p_main && (!bundle_resources) && res->get_path().length() && res->get_path().find("::") == -1) { + if (res->get_path() == local_path) { + ERR_PRINTS("Circular reference to resource being saved found: '"+local_path+"' will be null next time it's loaded."); + return; + } int index = external_resources.size(); external_resources[res] = index; return; |