diff options
author | ivan.penkov@gmail.com <ivan.penkov@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2013-05-23 18:47:49 +0000 |
---|---|---|
committer | ivan.penkov@gmail.com <ivan.penkov@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2013-05-23 18:47:49 +0000 |
commit | 5bdee65f7a63f18c6145a92963f0f044165d4d7f (patch) | |
tree | 00ece428ea82d64017176d539856b48deed13a05 /src/common/memory_unittest.cc | |
parent | Fixing several instances of std::vector::operator[] out of range access (diff) | |
download | breakpad-5bdee65f7a63f18c6145a92963f0f044165d4d7f.tar.xz |
Thanks to Matthew Riley who noticed this issue and provided the initial proposal for the fix.
There's a bug in the new allocator<T> implementation used by wasteful_vector. It inherits the base class' implementation of allocator and doesn't implement allocate() so it goes to the heap instead of the PageAllocator -- the very thing wasteful_vector was trying to avoid! As a side effect it was also leaking heap memory.
Thanks,
-Ivan
Review URL: https://breakpad.appspot.com/599002
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1188 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/memory_unittest.cc')
-rw-r--r-- | src/common/memory_unittest.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/memory_unittest.cc b/src/common/memory_unittest.cc index 69d9f8ab..1e511ca5 100644 --- a/src/common/memory_unittest.cc +++ b/src/common/memory_unittest.cc @@ -87,3 +87,11 @@ TEST(WastefulVectorTest, Simple) { for (unsigned i = 0; i < 256; ++i) ASSERT_EQ(v[i], i); } + +TEST(WastefulVectorTest, UsesPageAllocator) { + PageAllocator allocator_; + wasteful_vector<unsigned> v(&allocator_); + + v.push_back(1); + ASSERT_TRUE(allocator_.OwnsPointer(&v[0])); +} |