From 4cc9b16077de431eeb1429302b2af2362328eac6 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 20 Jul 2020 12:24:21 +0200 Subject: [PATCH] Fix motor subtree being unreachable from ASCII protocol When get_direct_child() was invoked on an Axis Instrospectable with the string "motor" it instead returned an Introspectable for "motor_thermistor". This is because strncmp("motor", "motor_thermistor", 5) compares to 0. --- Firmware/fibre/cpp/include/fibre/introspection.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/fibre/cpp/include/fibre/introspection.hpp b/Firmware/fibre/cpp/include/fibre/introspection.hpp index f52b73a8..f7e43f68 100644 --- a/Firmware/fibre/cpp/include/fibre/introspection.hpp +++ b/Firmware/fibre/cpp/include/fibre/introspection.hpp @@ -96,7 +96,7 @@ public: private: Introspectable get_direct_child(const char * name, size_t length) const { for (size_t i = 0; i < type_info_->property_table_length_; ++i) { - if (!strncmp(name, type_info_->property_table_[i].name, length)) { + if (!strncmp(name, type_info_->property_table_[i].name, length) && (length == strlen(type_info_->property_table_[i].name))) { Introspectable result; result.storage_ = type_info_->get_child(storage_, i); result.type_info_ = type_info_->property_table_[i].type_info;