Creating an OfflinePacketFilter instance with an invalid filter should throw an invalid_pcap_filter exception but it appears it cleans up the pcap handle before throwing the exception and then again in the destructor which results in a invalid pointer for free().
Add this test case to offline_packet_filter_test.cpp:
TEST_F(OfflinePacketFilterTest, InvalidPcapFilterThrowsException) {
EXPECT_THROW(OfflinePacketFilter filter("this is not a valid filter", DataLinkType()), invalid_pcap_filter);
}
Running main() from gtest_main.cc
[==========] Running 5 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 5 tests from OfflinePacketFilterTest
[ RUN ] OfflinePacketFilterTest.CopyConstructor
[ OK ] OfflinePacketFilterTest.CopyConstructor (0 ms)
[ RUN ] OfflinePacketFilterTest.MatchesFilterEthTcp
[ OK ] OfflinePacketFilterTest.MatchesFilterEthTcp (1 ms)
[ RUN ] OfflinePacketFilterTest.MatchesFilterEth
[ OK ] OfflinePacketFilterTest.MatchesFilterEth (0 ms)
[ RUN ] OfflinePacketFilterTest.MatchesFilterSLLTcp
[ OK ] OfflinePacketFilterTest.MatchesFilterSLLTcp (0 ms)
[ RUN ] OfflinePacketFilterTest.InvalidPcapFilterThrowsException
Error in `tests/offline_packet_filter_test': free(): invalid pointer: 0x00007ffefb5113d0 Off
Creating an OfflinePacketFilter instance with an invalid filter should throw an invalid_pcap_filter exception but it appears it cleans up the pcap handle before throwing the exception and then again in the destructor which results in a invalid pointer for free().
Add this test case to offline_packet_filter_test.cpp:
TEST_F(OfflinePacketFilterTest, InvalidPcapFilterThrowsException) { EXPECT_THROW(OfflinePacketFilter filter("this is not a valid filter", DataLinkType()), invalid_pcap_filter); }
Running main() from gtest_main.cc [==========] Running 5 tests from 1 test case. [----------] Global test environment set-up. [----------] 5 tests from OfflinePacketFilterTest [ RUN ] OfflinePacketFilterTest.CopyConstructor [ OK ] OfflinePacketFilterTest.CopyConstructor (0 ms) [ RUN ] OfflinePacketFilterTest.MatchesFilterEthTcp [ OK ] OfflinePacketFilterTest.MatchesFilterEthTcp (1 ms) [ RUN ] OfflinePacketFilterTest.MatchesFilterEth [ OK ] OfflinePacketFilterTest.MatchesFilterEth (0 ms) [ RUN ] OfflinePacketFilterTest.MatchesFilterSLLTcp [ OK ] OfflinePacketFilterTest.MatchesFilterSLLTcp (0 ms) [ RUN ] OfflinePacketFilterTest.InvalidPcapFilterThrowsException Error in `tests/offline_packet_filter_test': free(): invalid pointer: 0x00007ffefb5113d0 Off