Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overflow in spectrum size #89

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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