summaryrefslogtreecommitdiffstats
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 5a79647cb..30ca6635e 100644
--- a/libutils/VectorImpl.cpp
+++ b/libutils/VectorImpl.cpp
@@ -384,7 +384,11 @@ void* VectorImpl::_grow(size_t where, size_t amount)
384 { 384 {
385 const SharedBuffer* cur_sb = SharedBuffer::bufferFromData(mStorage); 385 const SharedBuffer* cur_sb = SharedBuffer::bufferFromData(mStorage);
386 SharedBuffer* sb = cur_sb->editResize(new_capacity * mItemSize); 386 SharedBuffer* sb = cur_sb->editResize(new_capacity * mItemSize);
387 mStorage = sb->data(); 387 if (sb) {
388 mStorage = sb->data();
389 } else {
390 return NULL;
391 }
388 } else { 392 } else {
389 SharedBuffer* sb = SharedBuffer::alloc(new_capacity * mItemSize); 393 SharedBuffer* sb = SharedBuffer::alloc(new_capacity * mItemSize);
390 if (sb) { 394 if (sb) {
@@ -399,6 +403,8 @@ void* VectorImpl::_grow(size_t where, size_t amount)
399 } 403 }
400 release_storage(); 404 release_storage();
401 mStorage = const_cast<void*>(array); 405 mStorage = const_cast<void*>(array);
406 } else {
407 return NULL;
402 } 408 }
403 } 409 }
404 } else { 410 } else {
@@ -436,7 +442,11 @@ void VectorImpl::_shrink(size_t where, size_t amount)
436 { 442 {
437 const SharedBuffer* cur_sb = SharedBuffer::bufferFromData(mStorage); 443 const SharedBuffer* cur_sb = SharedBuffer::bufferFromData(mStorage);
438 SharedBuffer* sb = cur_sb->editResize(new_capacity * mItemSize); 444 SharedBuffer* sb = cur_sb->editResize(new_capacity * mItemSize);
439 mStorage = sb->data(); 445 if (sb) {
446 mStorage = sb->data();
447 } else {
448 return;
449 }
440 } else { 450 } else {
441 SharedBuffer* sb = SharedBuffer::alloc(new_capacity * mItemSize); 451 SharedBuffer* sb = SharedBuffer::alloc(new_capacity * mItemSize);
442 if (sb) { 452 if (sb) {
@@ -451,6 +461,8 @@ void VectorImpl::_shrink(size_t where, size_t amount)
451 } 461 }
452 release_storage(); 462 release_storage();
453 mStorage = const_cast<void*>(array); 463 mStorage = const_cast<void*>(array);
464 } else{
465 return;
454 } 466 }
455 } 467 }
456 } else { 468 } else {