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:
@@ -37,11 +37,14 @@ using std::string;
|
|||||||
namespace Tins {
|
namespace Tins {
|
||||||
|
|
||||||
OfflinePacketFilter::OfflinePacketFilter(const OfflinePacketFilter& other) {
|
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) {
|
OfflinePacketFilter& OfflinePacketFilter::operator=(const OfflinePacketFilter& other) {
|
||||||
string_filter_ = other.string_filter_;
|
string_filter_ = other.string_filter_;
|
||||||
|
pcap_freecode(&filter_);
|
||||||
|
pcap_close(handle_);
|
||||||
init(string_filter_, pcap_datalink(other.handle_), pcap_snapshot(other.handle_));
|
init(string_filter_, pcap_datalink(other.handle_), pcap_snapshot(other.handle_));
|
||||||
return* this;
|
return* this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user