summaryrefslogtreecommitdiffstats
path: root/libutils/VectorImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libutils/VectorImpl.cpp')
-rw-r--r--libutils/VectorImpl.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp
index 3bcf54b..de65a6c 100644
--- a/libutils/VectorImpl.cpp
+++ b/libutils/VectorImpl.cpp
@@ -411,7 +411,11 @@ void* VectorImpl::_grow(size_t where, size_t amount)
{
const SharedBuffer* cur_sb = SharedBuffer::bufferFromData(mStorage);
SharedBuffer* sb = cur_sb->editResize(new_alloc_size);
- mStorage = sb->data();
+ if (sb) {
+ mStorage = sb->data();
+ } else {
+ return NULL;
+ }
} else {
SharedBuffer* sb = SharedBuffer::alloc(new_alloc_size);
if (sb) {
@@ -426,6 +430,8 @@ void* VectorImpl::_grow(size_t where, size_t amount)
}
release_storage();
mStorage = const_cast<void*>(array);
+ } else {
+ return NULL;
}
}
} else {
@@ -472,7 +478,11 @@ void VectorImpl::_shrink(size_t where, size_t amount)
{
const SharedBuffer* cur_sb = SharedBuffer::bufferFromData(mStorage);
SharedBuffer* sb = cur_sb->editResize(new_capacity * mItemSize);
- mStorage = sb->data();
+ if (sb) {
+ mStorage = sb->data();
+ } else {
+ return;
+ }
} else {
SharedBuffer* sb = SharedBuffer::alloc(new_capacity * mItemSize);
if (sb) {
@@ -487,6 +497,8 @@ void VectorImpl::_shrink(size_t where, size_t amount)
}
release_storage();
mStorage = const_cast<void*>(array);
+ } else{
+ return;
}
}
} else {