Fix overlap check in rdcarray::insert

This fixes an infinite when attempting to call `insert(0, NULL, 0)`
on an empty `rdcarray`.

The new behaviour also triggers a copy when the inserted interval
overlaps the `rdcarray`'s *allocated* memory (rather than just the
currently used prefixed).

Change-Id: I075827d50a24d0560ca391224820334e467a41f5
This commit is contained in:
Benson Joeris
2019-12-16 17:04:05 +00:00
committed by Baldur Karlsson
parent 722d24a96e
commit b8fbdf399b
2 changed files with 67 additions and 2 deletions
+1 -1
View File
@@ -439,7 +439,7 @@ public:
void insert(size_t offs, const T *el, size_t count)
{
if(el + count >= begin() && end() >= el)
if(elems < el + count && el < elems + allocatedCount)
{
// we're inserting from ourselves, so if we did this blindly we'd potentially change the
// contents of the inserted range while doing the insertion.