Index: third_party/tcmalloc/chromium/src/heap-profile-table.cc |
diff --git a/third_party/tcmalloc/chromium/src/heap-profile-table.cc b/third_party/tcmalloc/chromium/src/heap-profile-table.cc |
index 6d75c4a49a861320dd2eb500e9a23058ef54fd07..893fd4e98a26e365d77fab4dd4460698513c93c8 100644 |
--- a/third_party/tcmalloc/chromium/src/heap-profile-table.cc |
+++ b/third_party/tcmalloc/chromium/src/heap-profile-table.cc |
@@ -301,8 +301,11 @@ int HeapProfileTable::UnparseBucket(const Bucket& b, |
HeapProfileTable::Bucket** |
HeapProfileTable::MakeSortedBucketList() const { |
+ // We allocate memory for (num_buckets_ + 1) buckets |
+ // because this allocations itself could create a new bucket. |
+ // There is no harm even if it doesn't create a new bucket. |
Bucket** list = |
- reinterpret_cast<Bucket**>(alloc_(sizeof(Bucket) * num_buckets_)); |
+ reinterpret_cast<Bucket**>(alloc_(sizeof(Bucket) * (num_buckets_ + 1))); |
int n = 0; |
for (int b = 0; b < kHashTableSize; b++) { |