Skip to content

Commit

Permalink
fix coverity issues 1076296, 98 (null deref), re #11062
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed Feb 14, 2015
1 parent 7387264 commit 4882093
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Code/Mantid/Framework/Geometry/src/Instrument/Detector.cpp
Expand Up @@ -45,10 +45,14 @@ Detector::~Detector() {}
* @returns the detector id
*/
detid_t Detector::getID() const {
if (m_map)
return dynamic_cast<const Detector *>(m_base)->getID();
else
return m_id;
if (m_map) {
const Detector *d = dynamic_cast<const Detector *>(m_base);
if (d) {
return d->getID();
}
}

return m_id;
}

/// Get the distance between the detector and another component
Expand Down Expand Up @@ -137,10 +141,14 @@ bool Detector::isMasked() const {
/// Is the detector a monitor?
///@return true if it is a monitor
bool Detector::isMonitor() const {
if (m_map)
return dynamic_cast<const Detector *>(m_base)->isMonitor();
else
return m_isMonitor;
if (m_map) {
const Detector *d = dynamic_cast<const Detector *>(m_base);
if (d) {
return d->isMonitor();
}
}

return m_isMonitor;
}

/** Sets the flag for whether this detector object is a monitor
Expand Down

0 comments on commit 4882093

Please sign in to comment.