diff options
author | luigi1111 <luigi1111w@gmail.com> | 2021-09-23 22:16:38 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2021-09-23 22:16:38 -0500 |
commit | e7a1a095acb28afc12f64d3c9663f5f19ec68b1e (patch) | |
tree | e99b9398ceb2e8f0d1dfb9c1e5b2a95c824f540b /tests | |
parent | Merge pull request #7917 (diff) | |
parent | unit_tests: fix use after free in serialization test (diff) | |
download | monero-e7a1a095acb28afc12f64d3c9663f5f19ec68b1e.tar.xz |
Merge pull request #7923
5eaedb5 unit_tests: fix use after free in serialization test (moneromooo-monero)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit_tests/serialization.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index 535752665..f4c73d3d5 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -132,7 +132,8 @@ TEST(Serialization, BinaryArchiveInts) { ASSERT_EQ(8, oss.str().size()); ASSERT_EQ(string("\0\0\0\0\xff\0\0\0", 8), oss.str()); - binary_archive<false> iar{epee::strspan<std::uint8_t>(oss.str())}; + const std::string s = oss.str(); + binary_archive<false> iar{epee::strspan<std::uint8_t>(s)}; iar.serialize_int(x1); ASSERT_EQ(8, iar.getpos()); ASSERT_TRUE(iar.good()); @@ -150,7 +151,8 @@ TEST(Serialization, BinaryArchiveVarInts) { ASSERT_EQ(6, oss.str().size()); ASSERT_EQ(string("\x80\x80\x80\x80\xF0\x1F", 6), oss.str()); - binary_archive<false> iar{epee::strspan<std::uint8_t>(oss.str())}; + const std::string s = oss.str(); + binary_archive<false> iar{epee::strspan<std::uint8_t>(s)}; iar.serialize_varint(x1); ASSERT_TRUE(iar.good()); ASSERT_EQ(x, x1); |