From 1286a2dddb4cf95aa02cda581ec1e4eac3477665 Mon Sep 17 00:00:00 2001 From: Mateusz Jakub Fila Date: Thu, 15 Aug 2024 17:32:11 +0200 Subject: [PATCH] fix get metadata not checking if frame exists --- k4FWCore/include/k4FWCore/IMetadataSvc.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/k4FWCore/include/k4FWCore/IMetadataSvc.h b/k4FWCore/include/k4FWCore/IMetadataSvc.h index 019af862..8ad64727 100644 --- a/k4FWCore/include/k4FWCore/IMetadataSvc.h +++ b/k4FWCore/include/k4FWCore/IMetadataSvc.h @@ -37,7 +37,13 @@ class IMetadataSvc : virtual public IInterface { getFrame()->putParameter(name, obj); } - template std::optional get(const std::string& name) { return getFrame()->getParameter(name); } + template std::optional get(const std::string& name) { + auto* frame = getFrame(); + if (!frame) { + return std::nullopt; + } + return frame->getParameter(name); + } }; #endif