Skip to content
Snippets Groups Projects
Commit 4a3f65e0 authored by scott snyder's avatar scott snyder
Browse files

FourMom: Avoid conversion of null pointers to references.

Avoid a conversion of a null pointer to a reference, caught by ubsan.
parent 67f753f2
No related merge requests found
......@@ -35,6 +35,9 @@ public:
return *this;
}
T* get() { return m_theData; }
const T* get() const { return m_theData; }
T& operator*() { return *m_theData;}
const T& operator*() const { return *m_theData;}
......
......@@ -215,7 +215,7 @@ inline double P4ImplEEtaPhiM::e() const
inline const I4MomentumError* P4ImplEEtaPhiM::errors() const
{
return &(*m_error);
return m_error.get();
}
inline void P4ImplEEtaPhiM::setE( const double theE )
......
......@@ -228,8 +228,7 @@ inline double P4ImplIPtCotThPhiM::cotTh() const
inline const I4MomentumError* P4ImplIPtCotThPhiM::errors() const
{
// check if the pointer is empty before dereferencing
return (m_error ? &(*m_error) : 0);
return m_error.get();
}
// setters
......
......@@ -212,7 +212,7 @@ inline double P4ImplPtEtaPhiM::pt() const
inline const I4MomentumError* P4ImplPtEtaPhiM::errors() const
{
// check if the pointer is empty before dereferencing
return (m_error ? &(*m_error) : 0);
return m_error.get();
}
// setters
......
......@@ -219,7 +219,7 @@ inline double P4ImplPxPyPzE::e() const
inline const I4MomentumError* P4ImplPxPyPzE::errors() const
{
// check if the pointer is empty before dereferencing
return (m_error ? &(*m_error) : 0);
return m_error.get();
}
inline void P4ImplPxPyPzE::setPx( const double px )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment