Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1e07278 authored by Shuo Gao's avatar Shuo Gao Committed by Android Git Automerger
Browse files

am eb0eb4f7: fix corruption in Vector<> when malloc falied

* commit 'eb0eb4f7':
  fix corruption in Vector<> when malloc falied
parents c20d479f eb0eb4f7
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -384,7 +384,11 @@ void* VectorImpl::_grow(size_t where, size_t amount)
        {
            const SharedBuffer* cur_sb = SharedBuffer::bufferFromData(mStorage);
            SharedBuffer* sb = cur_sb->editResize(new_capacity * mItemSize);
            if (sb) {
                mStorage = sb->data();
            } else {
                return NULL;
            }
        } else {
            SharedBuffer* sb = SharedBuffer::alloc(new_capacity * mItemSize);
            if (sb) {
@@ -399,6 +403,8 @@ void* VectorImpl::_grow(size_t where, size_t amount)
                }
                release_storage();
                mStorage = const_cast<void*>(array);
            } else {
                return NULL;
            }
        }
    } else {
@@ -436,7 +442,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);
            if (sb) {
                mStorage = sb->data();
            } else {
                return;
            }
        } else {
            SharedBuffer* sb = SharedBuffer::alloc(new_capacity * mItemSize);
            if (sb) {
@@ -451,6 +461,8 @@ void VectorImpl::_shrink(size_t where, size_t amount)
                }
                release_storage();
                mStorage = const_cast<void*>(array);
            } else{
                return;
            }
        }
    } else {