diff options
author | Jacques Lucke <jacques@blender.org> | 2022-02-02 15:11:33 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-02-02 15:11:33 +0300 |
commit | bf8597febe2020e654020ad60e8af35c635c1a9a (patch) | |
tree | a55a1cb1b4a1268b6a11ebdde228b1a031a90042 /source/blender/blenlib/tests | |
parent | a985f558a6eb16cd6f00b550712b86923ab33fd3 (diff) |
BLI: fix memory leak in VectorSet
The leak happened when the vector set had to grow when it
was empty but it had allocated the keys array already.
Diffstat (limited to 'source/blender/blenlib/tests')
-rw-r--r-- | source/blender/blenlib/tests/BLI_vector_set_test.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_vector_set_test.cc b/source/blender/blenlib/tests/BLI_vector_set_test.cc index c4016ca75e1..fe3130a846f 100644 --- a/source/blender/blenlib/tests/BLI_vector_set_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_set_test.cc @@ -271,4 +271,14 @@ TEST(vector_set, LookupKey) EXPECT_EQ(set.lookup_key_ptr("a"), set.lookup_key_ptr_as("a")); } +TEST(vector_set, GrowWhenEmpty) +{ + /* Tests that the internal keys array is freed correctly when growing an empty set. */ + VectorSet<int> set; + set.add(4); + set.remove(4); + EXPECT_TRUE(set.is_empty()); + set.reserve(100); +} + } // namespace blender::tests |