From df7d99bb765d7fc4ee697985bdc84b9bc65412e0 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 14:05:18 +0000 Subject: [PATCH] fix(test): remove two undefined reads - PluginServices.Control: the condition variable predicate could read nextState before the callback wrote it; initialize it - MemoryResources.allocator: &*v.end() dereferences the end iterator; compute the end address from v.data() + v.size() Co-Authored-By: Claude Opus 5.5 --- test/memory_resources/_memory_resources.cxx | 3 ++- test/plugin_services/_control.cxx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/memory_resources/_memory_resources.cxx b/test/memory_resources/_memory_resources.cxx index 83918e0d..f4511cff 100644 --- a/test/memory_resources/_memory_resources.cxx +++ b/test/memory_resources/_memory_resources.cxx @@ -15,6 +15,7 @@ #include +#include #include #include #include @@ -117,7 +118,7 @@ TEST(MemoryResources, allocator) v.emplace_back(1); v.emplace_back(2); v.emplace_back(3); - EXPECT_TRUE((fair::mq::byte*)&(*v.end()) - (fair::mq::byte*)&(*v.begin()) == 3 * sizeof(TestData)); + EXPECT_EQ(reinterpret_cast(v.data() + v.size()) - reinterpret_cast(v.data()), static_cast(3 * sizeof(TestData))); EXPECT_TRUE(TestData::nallocated == 3); } EXPECT_TRUE(TestData::nallocated == 0); diff --git a/test/plugin_services/_control.cxx b/test/plugin_services/_control.cxx index 870a9eab..e66693b5 100644 --- a/test/plugin_services/_control.cxx +++ b/test/plugin_services/_control.cxx @@ -63,7 +63,7 @@ TEST_F(PluginServices, Control) ASSERT_NO_THROW(mServices.TakeDeviceControl("foo")); ASSERT_NO_THROW(mServices.ChangeDeviceState("foo", DeviceStateTransition::InitDevice)); - DeviceState nextState; + DeviceState nextState{DeviceState::Undefined}; condition_variable cv; mutex cv_m; mServices.SubscribeToDeviceStateChange("test", [&](DeviceState newState){