Skip to content

Commit

Permalink
Fix undefined behavior in VectorImpl
Browse files Browse the repository at this point in the history
Summary: memcpy on null operands is undefined, add a test.

Reviewed By: yuxuanchen1997

Differential Revision: D18075640

fbshipit-source-id: cb1380d5130e102c2ca09bd343ebed9335a3190a
  • Loading branch information
agampe authored and facebook-github-bot committed Oct 24, 2019
1 parent 7f70006 commit 489a085
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libresource/VectorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ ssize_t VectorImpl::insertArrayAt(const void* array, size_t index, size_t length
{
if (index > size())
return BAD_INDEX;
if (!length) {
return index;
}
void* where = _grow(index, length);
if (where) {
_do_copy(where, array, length);
Expand Down Expand Up @@ -640,4 +643,3 @@ ssize_t SortedVectorImpl::remove(const void* item)
/*****************************************************************************/

}; // namespace android

0 comments on commit 489a085

Please sign in to comment.