From 064439236c39057b5ac97914087fc97a3dd0822c Mon Sep 17 00:00:00 2001 From: Derrick Lyndon Pallas Date: Thu, 11 Apr 2019 18:12:26 +0000 Subject: [PATCH] OfflinePacketFilter: avoid leak during copy-construction or assignment --- src/offline_packet_filter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; }