mirror of
https://github.com/mfontanini/libtins
synced 2026-01-22 18:25:57 +01:00
OfflinePacketFilter: avoid leak during copy-construction or assignment
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user