summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Lyndon Pallas <derrick@argosylabs.com>2019-04-11 18:12:26 +0000
committerDerrick Lyndon Pallas <derrick@argosylabs.com>2019-04-11 18:20:53 +0000
commit064439236c39057b5ac97914087fc97a3dd0822c (patch)
tree5b269102804ac8bc70d47609ab0f796c59061506
parent0c40a0714b51952cf5b0ec8fcf56ae15de9e24b0 (diff)
OfflinePacketFilter: avoid leak during copy-construction or assignment
-rw-r--r--src/offline_packet_filter.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/offline_packet_filter.cpp b/src/offline_packet_filter.cpp
index ad8878a..c57b827 100644
--- a/src/offline_packet_filter.cpp
+++ b/src/offline_packet_filter.cpp
@@ -37,11 +37,14 @@ using std::string;
namespace Tins {
OfflinePacketFilter::OfflinePacketFilter(const OfflinePacketFilter& other) {
- *this = other;
+ string_filter_ = other.string_filter_;
+ init(string_filter_, pcap_datalink(other.handle_), pcap_snapshot(other.handle_));
}
OfflinePacketFilter& OfflinePacketFilter::operator=(const OfflinePacketFilter& other) {
string_filter_ = other.string_filter_;
+ pcap_freecode(&filter_);
+ pcap_close(handle_);
init(string_filter_, pcap_datalink(other.handle_), pcap_snapshot(other.handle_));
return* this;
}