From c7d9c3b21f191587a42673f2f563b1c29d43f03a Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Tue, 6 Sep 2022 14:21:01 +0100 Subject: [PATCH] Fix uninitialized data reads in Input Found by Valgrind. (cherry picked from commit d60eae3dbca08b4bad2c34c270c072a856cd8bc8) --- core/os/input_event.cpp | 8 ++++---- scene/gui/tree.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 985efad6cb8..740366db538 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -49,25 +49,25 @@ bool InputEvent::is_action(const StringName &p_action, bool p_exact_match) const } bool InputEvent::is_action_pressed(const StringName &p_action, bool p_allow_echo, bool p_exact_match) const { - bool pressed; + bool pressed = false; bool valid = InputMap::get_singleton()->event_get_action_status(Ref((InputEvent *)this), p_action, p_exact_match, &pressed, nullptr, nullptr); return valid && pressed && (p_allow_echo || !is_echo()); } bool InputEvent::is_action_released(const StringName &p_action, bool p_exact_match) const { - bool pressed; + bool pressed = false; bool valid = InputMap::get_singleton()->event_get_action_status(Ref((InputEvent *)this), p_action, p_exact_match, &pressed, nullptr, nullptr); return valid && !pressed; } float InputEvent::get_action_strength(const StringName &p_action, bool p_exact_match) const { - float strength; + float strength = 0.0f; bool valid = InputMap::get_singleton()->event_get_action_status(Ref((InputEvent *)this), p_action, p_exact_match, nullptr, &strength, nullptr); return valid ? strength : 0.0f; } float InputEvent::get_action_raw_strength(const StringName &p_action, bool p_exact_match) const { - float raw_strength; + float raw_strength = 0.0f; bool valid = InputMap::get_singleton()->event_get_action_status(Ref((InputEvent *)this), p_action, p_exact_match, nullptr, nullptr, &raw_strength); return valid ? raw_strength : 0.0f; } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index e544dd10d77..44647596788 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2405,7 +2405,7 @@ void Tree::_gui_input(Ref p_event) { TreeItem *old_it = cache.hover_item; int old_col = cache.hover_cell; - int col, h, section; + int col = 0, h = 0, section = 0; TreeItem *it = _find_item_at_pos(root, mpos, col, h, section); if (drop_mode_flags) {