diff --git a/include/podio/Frame.h b/include/podio/Frame.h index d7b712703..b74fd8990 100644 --- a/include/podio/Frame.h +++ b/include/podio/Frame.h @@ -150,7 +150,10 @@ class Frame { /// /// @tparam FrameDataT Arbitrary data container that provides access to the /// collection buffers as well as the metadata, when - /// requested by the Frame. + /// requested by the Frame. The unique_ptr has to be checked + /// for validity before calling this construtor. + /// + /// @throws std::invalid_argument if the passed pointer is a nullptr. template Frame(std::unique_ptr); @@ -391,11 +394,15 @@ const CollT& Frame::put(CollT&& coll, const std::string& name) { template Frame::FrameModel::FrameModel(std::unique_ptr data) : - m_mapMtx(std::make_unique()), - m_data(std::move(data)), - m_dataMtx(std::make_unique()), - m_idTable(std::move(m_data->getIDTable())), - m_parameters(std::move(m_data->getParameters())) { + m_mapMtx(std::make_unique()), m_dataMtx(std::make_unique()) { + if (!data) { + throw std::invalid_argument( + "FrameData is a nullptr. If you are reading from a file it may be corrupted or you may reading beyond the end " + "of the file, please check the validity of the data before creating a Frame."); + } + m_data = std::move(data); + m_idTable = std::move(m_data->getIDTable()); + m_parameters = std::move(m_data->getParameters()); } template