Fix crash in rdcarray comparison

This commit is contained in:
baldurk
2021-11-23 12:41:40 +00:00
parent e3e50fd9e4
commit c8c3cc35fc
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -182,7 +182,7 @@ public:
c = o.usedCount;
// compare the range
int comp = ItemHelper<T>::compRange(elems, o.elems, usedCount);
int comp = ItemHelper<T>::compRange(elems, o.elems, c);
// if it's not equal, we can return either true or false now
if(comp != 0)
return (comp < 0);
+14
View File
@@ -250,6 +250,13 @@ TEST_CASE("Test array type", "[basictypes]")
CHECK(test2 < test);
CHECK_FALSE(test < test2);
CHECK_FALSE(test == test2);
// ensure in the case of comparing different sized arrays we don't read off the end of one
rdcarray<int> emptyTest;
CHECK(emptyTest < test);
CHECK_FALSE(test < emptyTest);
CHECK_FALSE(test == test2);
};
SECTION("Comparison test with non-trivial type")
@@ -293,6 +300,13 @@ TEST_CASE("Test array type", "[basictypes]")
CHECK(test2 < test);
CHECK_FALSE(test < test2);
CHECK_FALSE(test == test2);
// ensure in the case of comparing different sized arrays we don't read off the end of one
rdcarray<NonTrivial> emptyTest;
CHECK(emptyTest < test);
CHECK_FALSE(test < emptyTest);
CHECK_FALSE(test == test2);
}
SECTION("Test constructing/assigning from other types")