Skip to content

Commit

Permalink
Merge pull request #89 from ISISComputingGroup/fix_overflow
Browse files Browse the repository at this point in the history
Fix overflow in spectrum size
  • Loading branch information
FreddieAkeroyd authored Jan 16, 2025
2 parents 7f58c94 + d5d04d0 commit 4c56e06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions isisdaeApp/src/NORDPV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ NORDSPECPV<T>::NORDSPECPV ( exServer & cas, pvInfo &setup, bool preCreateFlag, b
template <typename T>
bool NORDSPECPV<T>::getNewValue(smartGDDPointer& pDD)
{
int nmax = static_cast<int>(this->info.getHopr());
try {
setNORD(cas.iface()->getSpectrumSize(m_spec) + (m_is_edges ? 1 : 0));
int n = cas.iface()->getSpectrumSize(m_spec) + (m_is_edges ? 1 : 0);
n = (n > nmax ? nmax : n); // we may not have allocated enough space so truncate - isisicp may have been reconfigured with a larger size
setNORD(n);
}
catch(const std::exception& ex) {
std::cerr << "CAS: Exception in NORDSPECPV::getNewValue(): " << ex.what() << std::endl;
Expand All @@ -61,9 +64,12 @@ NORDMONPV<T>::NORDMONPV ( exServer & cas, pvInfo &setup, bool preCreateFlag, boo
template <typename T>
bool NORDMONPV<T>::getNewValue(smartGDDPointer& pDD)
{
int nmax = static_cast<int>(this->info.getHopr());
try {
int spec = cas.iface()->getSpectrumNumberForMonitor(m_mon);
setNORD(cas.iface()->getSpectrumSize(spec) + (m_is_edges ? 1 : 0));
int n = cas.iface()->getSpectrumSize(spec) + (m_is_edges ? 1 : 0);
n = (n > nmax ? nmax : n); // we may not have allocated enough space so truncate - isisicp may have been reconfigured with a larger size
setNORD(n);
}
catch(const std::exception& ex) {
std::cerr << "CAS: Exception in NORDMONPV::getNewValue(): " << ex.what() << std::endl;
Expand Down
1 change: 1 addition & 0 deletions isisdaeApp/src/SpectrumPV.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ bool SpectrumPV::getNewValue(smartGDDPointer& pDD)
delete[] pY;
return false;
}
n = (n > nmax ? nmax : n); // we may not have allocated enough space so truncate - isisicp may have been reconfigured with a larger size
if (m_axis == "Y" || m_axis == "YC")
{
m_nord = n; // number of elements used
Expand Down

0 comments on commit 4c56e06

Please sign in to comment.