Fix use after free in FlatbufferEqMatcher
We were using a Span instead of an owning container for our flatbuffer.
The backing data for the span was going out of scope, so we were getting
a use after free. Go back to Vector. The speedup isn't worth the
complexity.
Change-Id: I3938f745d2f31ae76702a2de422f0aa3c5b831d0
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/testing/flatbuffer_eq.h b/aos/testing/flatbuffer_eq.h
index c4b708b..2f7b345 100644
--- a/aos/testing/flatbuffer_eq.h
+++ b/aos/testing/flatbuffer_eq.h
@@ -51,7 +51,7 @@
template <typename T>
class FlatbufferEqMatcher : public ::testing::MatcherInterface<const T *> {
public:
- FlatbufferEqMatcher(aos::FlatbufferSpan<T> expected)
+ FlatbufferEqMatcher(aos::FlatbufferVector<T> expected)
: expected_(std::move(expected)) {}
~FlatbufferEqMatcher() override = default;
@@ -70,7 +70,7 @@
}
private:
- const aos::FlatbufferSpan<T> expected_;
+ const aos::FlatbufferVector<T> expected_;
};
// Returns a googlemock matcher which will compare a `const T *` or a `const
@@ -81,7 +81,7 @@
template <typename T>
inline auto FlatbufferEq(const aos::NonSizePrefixedFlatbuffer<T> &expected) {
return FlatbufferUnwrapped(::testing::MakeMatcher(
- new FlatbufferEqMatcher(aos::FlatbufferSpan<T>(expected))));
+ new FlatbufferEqMatcher(aos::FlatbufferVector<T>(expected))));
}
} // namespace testing