diff options
| author | Derrick Lyndon Pallas <derrick@argosylabs.com> | 2019-04-11 18:12:26 +0000 |
|---|---|---|
| committer | Derrick Lyndon Pallas <derrick@argosylabs.com> | 2019-04-11 18:20:53 +0000 |
| commit | 064439236c39057b5ac97914087fc97a3dd0822c (patch) | |
| tree | 5b269102804ac8bc70d47609ab0f796c59061506 | |
| parent | 0c40a0714b51952cf5b0ec8fcf56ae15de9e24b0 (diff) | |
OfflinePacketFilter: avoid leak during copy-construction or assignment
| -rw-r--r-- | src/offline_packet_filter.cpp | 5 |
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; } |
