Skip to content
Snippets Groups Projects
Commit f77f6429 authored by Takashi Yamanaka's avatar Takashi Yamanaka
Browse files

Merge branch 'ether.GeoModelKernel-20170327' into 'master'

GeoModelKernel: Avoid out-of-bounds array access.

See merge request !595
parents 1cbc5ae5 5072d144
1 merge request!20779WIP: Migrate DataQualityTools to ToolHandles
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <cfloat> #include <cfloat>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <iterator>
//## end module%3CD878BB0006.includes //## end module%3CD878BB0006.includes
...@@ -379,7 +380,10 @@ void GeoMaterial::lock () ...@@ -379,7 +380,10 @@ void GeoMaterial::lock ()
int iZ = (int) (m_element[e]->getZ () + 0.5) - 1; // Atomic number index int iZ = (int) (m_element[e]->getZ () + 0.5) - 1; // Atomic number index
dEDxConstant += w * C0 * dovera * Z; dEDxConstant += w * C0 * dovera * Z;
dEDxI0 += w * s_ionizationPotential[iZ]; // Make sure we don't overflow the table:
// the `Ether' special `element' has Z set to 500.
if (iZ >= 0 && iZ < (std::end(s_ionizationPotential)-std::begin(s_ionizationPotential)))
dEDxI0 += w * s_ionizationPotential[iZ];
NILinv += n * pow (N, 2.0 / 3.0) * CLHEP::amu * inv_lambda0; NILinv += n * pow (N, 2.0 / 3.0) * CLHEP::amu * inv_lambda0;
double nAtomsPerVolume = A ? CLHEP::Avogadro*m_density*m_fraction[e]/A : 0.; double nAtomsPerVolume = A ? CLHEP::Avogadro*m_density*m_fraction[e]/A : 0.;
......
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