]> granicus.if.org Git - taglib/commitdiff
Added a test for out-of-bounds access in findVector().
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Thu, 19 Jun 2014 04:22:50 +0000 (13:22 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Thu, 19 Jun 2014 04:22:50 +0000 (13:22 +0900)
tests/test_bytevector.cpp

index eca74f8ff2a9a3c74bca004ac0102c447de9354f..c6a96198743288987bab690ae3a4cd8b5b9205bc 100644 (file)
@@ -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()