fixed various memory leaks/overruns/etc

I found many issues using AddressSanitizer and LeakSanitizer.
diff --git a/bbb_cape/src/bbb/cows_test.cc b/bbb_cape/src/bbb/cows_test.cc
index 06eba5b..e75af6b 100644
--- a/bbb_cape/src/bbb/cows_test.cc
+++ b/bbb_cape/src/bbb/cows_test.cc
@@ -7,8 +7,8 @@
 TEST(CowsTest, StupidZeros) {
   static const uint8_t kTestInput[] = {0x02, 0x00, 0x00, 0x00, 0x00, 0x08, 0x01,
                                        0x00};
-  uint32_t input[3];
-  memcpy(input, kTestInput, 12);
+  uint32_t input[2];
+  memcpy(input, kTestInput, 8);
   uint32_t output[2];
   EXPECT_EQ(
       1u, cows_unstuff(input, sizeof(kTestInput), output, sizeof(output) * 4));
diff --git a/bbb_cape/src/bbb/packet_finder.cc b/bbb_cape/src/bbb/packet_finder.cc
index 783ce32..43363b8 100644
--- a/bbb_cape/src/bbb/packet_finder.cc
+++ b/bbb_cape/src/bbb/packet_finder.cc
@@ -36,8 +36,8 @@
 }
 
 PacketFinder::~PacketFinder() {
-  delete buf_;
-  delete unstuffed_data_;
+  delete[] buf_;
+  delete[] unstuffed_data_;
 }
 
 bool PacketFinder::FindPacket(const ::Time &timeout_time) {
diff --git a/bbb_cape/src/bbb/packet_finder_test.cc b/bbb_cape/src/bbb/packet_finder_test.cc
index dddf0ec..b4937b1 100644
--- a/bbb_cape/src/bbb/packet_finder_test.cc
+++ b/bbb_cape/src/bbb/packet_finder_test.cc
@@ -58,7 +58,9 @@
       }
       EXPECT_EQ(!expect_failure,
                 packet_finder.ReadPacket(::aos::time::Time(0, 0)));
-      if (expect_failure && i + 1 != *failure && i + 1 != packets) {
+      if (expect_failure &&
+          (failure == expected_failures.end() || i + 1 != *failure) &&
+          i + 1 != packets) {
         int failures = 0;
         while (!packet_finder.ReadPacket(::aos::time::Time(0, 0))) {
           ++failures;