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.
This commit is contained in:
Andreas Haas 2017-04-02 09:46:51 +02:00
parent 6731924dcf
commit 1d3c9c448d
No known key found for this signature in database
GPG key ID: B5FFAE1B65FBD2E1

View file

@ -1401,7 +1401,7 @@ void Viewport::_vp_input(const InputEvent &p_ev) {
return; return;
#ifdef TOOLS_ENABLED #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; return;
} }
#endif #endif
@ -1422,7 +1422,7 @@ void Viewport::_vp_unhandled_input(const InputEvent &p_ev) {
if (disable_input) if (disable_input)
return; return;
#ifdef TOOLS_ENABLED #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; return;
} }
#endif #endif