Commit e34ba846 authored by Mikhail Karasikov's avatar Mikhail Karasikov Committed by Facebook Github Bot

throw std::bad_alloc if memory can't be allocated (#888)

Summary:
Bug fix: call `reserve()` trying to allocate more memory than available
Pull Request resolved: https://github.com/facebook/folly/pull/888

Reviewed By: ot

Differential Revision: D9234444

Pulled By: yfeldblum

fbshipit-source-id: 4d12236aee745ad663d95a370d273f619f92b1bd
parent c4fca6d0
......@@ -113,7 +113,7 @@ class fbvector {
// note that 'allocate' and 'deallocate' are inherited from Allocator
T* D_allocate(size_type n) {
if (usingStdAllocator::value) {
return static_cast<T*>(malloc(n * sizeof(T)));
return static_cast<T*>(checkedMalloc(n * sizeof(T)));
} else {
return std::allocator_traits<Allocator>::allocate(*this, n);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment