Fix StaticCache::getData() returning true on empty cache#908
Fix StaticCache::getData() returning true on empty cache#908ahcorde merged 1 commit intoros2:rollingfrom
Conversation
44a586f to
35576ea
Compare
|
Thank you for the PR! Please see my note here: ros2/rclcpp#3109 (comment) |
|
Thanks for the review! AI disclosure: This PR was authored with the assistance of Claude Opus (Anthropic) as a generative AI coding tool. I have reviewed and validated the changes. Branch target: Retargeting to |
StaticCache::getData() unconditionally returned true even when no data had been inserted, causing callers to read uninitialized storage. Add a populated_ flag that tracks whether insertData() has been called. getData() now returns false with an appropriate error when the cache is empty. Also fix clearList() to reset the flag and getListLength() to return 0 when empty. Fixes ros2#769 Signed-off-by: Pavel Guzenfeld <me@pavelguzenfeld.com> Signed-off-by: Pavel Guzenfeld <pavelguzenfeld@gmail.com>
35576ea to
2371ec4
Compare
|
Rebased onto The bug (reported in #769) also affects |
|
Pulls: #908 |
Summary
Fixes #769
StaticCache::getData()unconditionally returnedtrueeven when no data had been inserted viainsertData(). This caused callers to read uninitializedTransformStorage, leading to incorrect transform data.Changes:
populated_flag toStaticCachethat tracks whetherinsertData()has been calledgetData()now returnsfalsewithTF2_LOOKUP_ERRORwhen the cache is emptyclearList()resets thepopulated_flaggetListLength()returns 0 when empty (was hardcoded to 1)getParent()returns 0 when emptyTest plan
test_static_cache_unittestpasses — existing tests for populated cache still worktest_cache_unittestpasses — dynamic cache unaffected