@@ -61,15 +61,16 @@ namespace {{ns}} {
return;
}
- ipc_ = std::make_unique<IPCPipeUnixSocket>(ipam->path().c_str(),
- proxyWorkerPath.c_str());
- if (!ipc_->isConnected()) {
+ auto ipc = std::make_unique<IPCPipeUnixSocket>(ipam->path().c_str(),
+ proxyWorkerPath.c_str());
+ if (!ipc->isConnected()) {
LOG(IPAProxy, Error) << "Failed to create IPCPipe";
return;
}
- ipc_->recv.connect(this, &{{proxy_name}}::recvMessage);
+ ipc->recv.connect(this, &{{proxy_name}}::recvMessage);
+ ipc_ = std::move(ipc);
valid_ = true;
return;
}
@@ -96,7 +97,7 @@ namespace {{ns}} {
{{proxy_name}}::~{{proxy_name}}()
{
- if (isolate_) {
+ if (ipc_) {
IPCMessage::Header header =
{ static_cast<uint32_t>({{cmd_enum_name}}::Exit), seq_++ };
IPCMessage msg(header);
Only try to send the "Exit" message if the `ipc_` pointer is non-null. If the constructor fails, then `ipc_` might remain nullptr, which would lead to a nullptr dereference in the destructor. This change also modifies the constructor so that only a valid `IPCPipeUnixSocket` object will be saved into the `ipc_` member, which avoids error messages when `IPCPipeUnixSocket::sendAsync()` is called in the inappropriate state in the destructor. Bug: https://bugs.libcamera.org/show_bug.cgi?id=276 Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- changes in v2: * modify constructor not to save "invalid" IPCPipeUnixSocket into member v1: https://patchwork.libcamera.org/patch/23894/ --- .../libcamera_templates/module_ipa_proxy.cpp.tmpl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.50.1