1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

OfflinePacketFilter: avoid leak during copy-construction or assignment

This commit is contained in:
Derrick Lyndon Pallas
2019-04-11 18:12:26 +00:00
parent 0c40a0714b
commit 064439236c

View File

@@ -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;
}