parser_tests: Add invalid lacing test.

Also fixes leak this test exposed in mkvparser::Cluster.

Change-Id: I06ae11b72bc89219b6b2b407b4cc215982e3ae65
diff --git a/mkvparser/mkvparser.cc b/mkvparser/mkvparser.cc
index 2180115..58d7e33 100644
--- a/mkvparser/mkvparser.cc
+++ b/mkvparser/mkvparser.cc
@@ -6698,8 +6698,10 @@
 {}
 
 Cluster::~Cluster() {
-  if (m_entries_count <= 0)
+  if (m_entries_count <= 0) {
+    delete[] m_entries;
     return;
+  }
 
   BlockEntry** i = m_entries;
   BlockEntry** const j = m_entries + m_entries_count;
diff --git a/testing/parser_tests.cc b/testing/parser_tests.cc
index e5d88ba..1523504 100644
--- a/testing/parser_tests.cc
+++ b/testing/parser_tests.cc
@@ -759,6 +759,19 @@
                                              kCodecPrivateLength, NULL));
 }
 
+TEST_F(ParserTest, InvalidFixedLacingSize) {
+  filename_ = GetTestFilePath("invalid/fixed_lacing_bad_lace_size.mkv");
+  ASSERT_NE(0u, filename_.length());
+  ASSERT_EQ(0, reader_.Open(filename_.c_str()));
+  mkvparser::EBMLHeader ebml_header;
+  ASSERT_EQ(0, ebml_header.Parse(&reader_, pos_));
+  ASSERT_EQ(0, mkvparser::Segment::CreateInstance(&reader_, pos_, segment_));
+  ASSERT_EQ(0, segment_->Load());
+  const mkvparser::BlockEntry* block_entry = NULL;
+  EXPECT_EQ(mkvparser::E_FILE_FORMAT_INVALID,
+            segment_->GetFirst()->GetFirst(block_entry));
+}
+
 }  // namespace test
 
 int main(int argc, char* argv[]) {
diff --git a/testing/testdata/invalid/README.libwebm b/testing/testdata/invalid/README.libwebm
new file mode 100644
index 0000000..51fadf6
--- /dev/null
+++ b/testing/testdata/invalid/README.libwebm
@@ -0,0 +1,6 @@
+Why the files in this directory are considered invalid:
+
+fixed_lacing_bad_lace_size.mkv - File containing a BlockGroup with fixed
+                                 lacing, but reports a total laced size that is
+                                 not evenly divisible by the number of laced
+                                 frames.
diff --git a/testing/testdata/invalid/fixed_lacing_bad_lace_size.mkv b/testing/testdata/invalid/fixed_lacing_bad_lace_size.mkv
new file mode 100644
index 0000000..bbe2025
--- /dev/null
+++ b/testing/testdata/invalid/fixed_lacing_bad_lace_size.mkv
Binary files differ