Skip to content

Commit af25f53

Browse files
committed
fmq: guard against empty fmq messages during teardown
1 parent abda81e commit af25f53

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/ReadoutEmulator/ReadoutDevice.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ void ReadoutDevice::ResetTask()
104104
if (mSendingThread.joinable()) {
105105
mSendingThread.join();
106106
}
107+
108+
mDataRegion = nullptr;
107109
}
108110

109111
bool ReadoutDevice::ConditionalRun()

src/common/include/ReadoutDataModel.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,13 @@ class RDHReader {
237237
mRDHSize = sRDHReader->CheckRdhData(mData, mSize);
238238
}
239239

240-
explicit RDHReader(const FairMQMessagePtr &msg)
241-
: RDHReader(reinterpret_cast<const char*>(msg->GetData()), msg->GetSize()) { }
240+
explicit RDHReader(const FairMQMessagePtr &msg) {
241+
if (!msg) {
242+
throw std::runtime_error("RDHReader::msg is null");
243+
}
244+
245+
*this = std::move(RDHReader(reinterpret_cast<const char*>(msg->GetData()), msg->GetSize()));
246+
}
242247

243248
RDHReader(const RDHReader &b) = default;
244249
RDHReader(RDHReader &&b) = default;

0 commit comments

Comments
 (0)