mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 01:28:20 +00:00
Prevent exception in noexcept
function.
This commit is contained in:
parent
85ad6084e8
commit
3ea2d2760a
1 changed files with 24 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
@ -14,6 +15,9 @@
|
|||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include <hilti/rt/backtrace.h>
|
||||
|
||||
#include "zeek/Reporter.h"
|
||||
#include "zeek/Val.h"
|
||||
#include "zeek/analyzer/Analyzer.h"
|
||||
#include "zeek/analyzer/protocol/tcp/TCP.h"
|
||||
|
@ -129,10 +133,25 @@ struct Cookie {
|
|||
Cookie(cookie::ProtocolAnalyzer&& c) : data(std::move(c)) { protocol = &data.protocol; }
|
||||
Cookie(cookie::FileAnalyzer&& c) : data(std::move(c)) { file = &data.file; }
|
||||
Cookie(cookie::PacketAnalyzer&& c) : data(std::move(c)) { packet = &data.packet; }
|
||||
Cookie(Cookie&& other) noexcept : data(other.tag(), std::move(other.data)) { _initLike(other); }
|
||||
|
||||
Cookie(Cookie&& other) noexcept
|
||||
: data(
|
||||
[&]() {
|
||||
try {
|
||||
return other.tag();
|
||||
} catch ( const std::exception& e ) {
|
||||
auto type = hilti::rt::demangle(typeid(e).name());
|
||||
reporter->FatalError("terminating with uncaught exception of type %s: %s", type.c_str(),
|
||||
e.what());
|
||||
}
|
||||
}(),
|
||||
std::move(other.data)) {
|
||||
_initLike(other);
|
||||
}
|
||||
|
||||
~Cookie() { _delete(); }
|
||||
|
||||
Cookie& operator=(Cookie&& other) noexcept {
|
||||
Cookie& operator=(Cookie&& other) noexcept try {
|
||||
if ( this == &other )
|
||||
return *this;
|
||||
|
||||
|
@ -141,6 +160,9 @@ struct Cookie {
|
|||
|
||||
new (&data) Data(tag(), std::move(other.data));
|
||||
return *this;
|
||||
} catch ( const std::exception& e ) {
|
||||
auto type = hilti::rt::demangle(typeid(e).name());
|
||||
reporter->FatalError("terminating with uncaught exception of type %s: %s", type.c_str(), e.what());
|
||||
}
|
||||
|
||||
// Cache of values that can be expensive to compute.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue