summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-05-28 13:49:34 +0200
committerGitHub <noreply@github.com>2019-05-28 13:49:34 +0200
commitbf6f41e0b90faa8a234f4270f68c90a9c968b552 (patch)
treed9408112f5e06cb75f921ea6d9c1c633b6c9434b /scene
parent6273e4d76dd62fe123d90d81a46848a927678c99 (diff)
parent427040372443cd675c63495f0fab8c195b21319d (diff)
Merge pull request #26978 from qarmin/fix_recursive_bitmapfont_crash
Fix crash when trying to set as Bitmap Font fallback one of his parent
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/font.cpp8
-rw-r--r--scene/resources/material.cpp7
2 files changed, 13 insertions, 2 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 128db3f109..627397f0ab 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -530,7 +530,13 @@ Size2 Font::get_wordwrap_string_size(const String &p_string, float p_width) cons
void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) {
- ERR_FAIL_COND(p_fallback == this);
+ for (Ref<BitmapFont> fallback_child = p_fallback; fallback_child != NULL; fallback_child = fallback_child->get_fallback()) {
+ if (fallback_child == this) {
+ ERR_EXPLAIN("Can't set as fallback one of its parents to prevent crashes due to recursive loop.");
+ ERR_FAIL_COND(fallback_child == this);
+ }
+ }
+
fallback = p_fallback;
}
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 2e035bbd1f..ada0ac07a3 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -38,7 +38,12 @@
void Material::set_next_pass(const Ref<Material> &p_pass) {
- ERR_FAIL_COND(p_pass == this);
+ for (Ref<Material> pass_child = p_pass; pass_child != NULL; pass_child = pass_child->get_next_pass()) {
+ if (pass_child == this) {
+ ERR_EXPLAIN("Can't set as next_pass one of its parents to prevent crashes due to recursive loop.");
+ ERR_FAIL_COND(pass_child == this);
+ }
+ }
if (next_pass == p_pass)
return;