Avoid potential UB in loggers using composition

This cast would work fine, but any other fields added to those loggers
would be left uninitialized.
This commit is contained in:
Robbert van der Helm
2020-12-04 18:52:33 +01:00
parent c1e7f53cd0
commit 426231a22b
9 changed files with 76 additions and 22 deletions
+2 -1
View File
@@ -254,7 +254,8 @@ class EventHandler : public AdHocSocketHandler<Thread> {
};
this->receive_multi(
logging ? std::optional(std::ref(logging->first)) : std::nullopt,
logging ? std::optional(std::ref(logging->first.logger))
: std::nullopt,
[&](boost::asio::local::stream_protocol::socket& socket) {
process_event(socket, true);
},
+4 -3
View File
@@ -174,9 +174,10 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
write_object(socket, response);
};
this->receive_multi(
logging ? std::optional(std::ref(logging->first)) : std::nullopt,
process_message);
this->receive_multi(logging
? std::optional(std::ref(logging->first.logger))
: std::nullopt,
process_message);
}
};