mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
OfflinePacketFilter: avoid leaks on error in init
This commit is contained in:
@@ -58,8 +58,14 @@ void OfflinePacketFilter::init(const string& pcap_filter,
|
|||||||
link_type,
|
link_type,
|
||||||
snap_len
|
snap_len
|
||||||
);
|
);
|
||||||
|
if (!handle_) {
|
||||||
|
throw pcap_open_failed();
|
||||||
|
}
|
||||||
if (pcap_compile(handle_, &filter_, pcap_filter.c_str(), 1, 0xffffffff) == -1) {
|
if (pcap_compile(handle_, &filter_, pcap_filter.c_str(), 1, 0xffffffff) == -1) {
|
||||||
throw invalid_pcap_filter(pcap_geterr(handle_));
|
string error(pcap_geterr(handle_));
|
||||||
|
pcap_freecode(&filter_);
|
||||||
|
pcap_close(handle_);
|
||||||
|
throw invalid_pcap_filter(error.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user