am eb0eb4f7: fix corruption in Vector<> when malloc falied
* commit 'eb0eb4f79fca083009aa7a6b6e28ddcdbcbd1214':
fix corruption in Vector<> when malloc falied
diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp
index 5a79647..30ca663 100644
--- a/libutils/VectorImpl.cpp
+++ b/libutils/VectorImpl.cpp
@@ -384,7 +384,11 @@
{
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 NULL;
+ }
} else {
SharedBuffer* sb = SharedBuffer::alloc(new_capacity * mItemSize);
if (sb) {
@@ -399,6 +403,8 @@
}
release_storage();
mStorage = const_cast<void*>(array);
+ } else {
+ return NULL;
}
}
} else {
@@ -436,7 +442,11 @@
{
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) {
@@ -451,6 +461,8 @@
}
release_storage();
mStorage = const_cast<void*>(array);
+ } else{
+ return;
}
}
} else {