From 1d3c9c448d805d0813a67efdd6677c312d72bb32 Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Sun, 2 Apr 2017 09:46:51 +0200 Subject: Viewport: Fix undefined behaviour found by llvm sanitizer. When godot was running as the project manager, it tried to call a method on a null pointer (get_tree()->get_edited_scene_root()). This is undefined behaviour and caused a crash when compiled with sanitizing enabled. --- scene/main/viewport.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 23f8189167..3b8fd1ae3e 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1401,7 +1401,7 @@ void Viewport::_vp_input(const InputEvent &p_ev) { return; #ifdef TOOLS_ENABLED - if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { + if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { return; } #endif @@ -1422,7 +1422,7 @@ void Viewport::_vp_unhandled_input(const InputEvent &p_ev) { if (disable_input) return; #ifdef TOOLS_ENABLED - if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { + if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { return; } #endif -- cgit v1.2.3