From cb3abf15ad4aa10c3cdc5e7746b3a071e9907bda Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Thu, 19 Jun 2014 13:22:50 +0900 Subject: [PATCH] Added a test for out-of-bounds access in findVector(). --- tests/test_bytevector.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index eca74f8f..c6a96198 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -122,7 +122,7 @@ public: CPPUNIT_ASSERT(i.containsAt(j, 6, 1)); CPPUNIT_ASSERT(i.containsAt(j, 6, 1, 3)); } - + void testFind1() { CPPUNIT_ASSERT_EQUAL(4, ByteVector("....SggO."). find("SggO")); @@ -135,6 +135,12 @@ public: CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find("SggO", 6)); CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find("SggO", 7)); CPPUNIT_ASSERT_EQUAL(-1, ByteVector("....SggO."). find("SggO", 8)); + + // Intentional out-of-bounds access. + ByteVector v("0123456789x"); + v.resize(10); + v.data()[10] = 'x'; + CPPUNIT_ASSERT_EQUAL(-1, v.find("789x", 7)); } void testFind2()