Skip to content
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
9 changes: 8 additions & 1 deletion Framework/Kernel/src/FilteredTimeSeriesProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ template <typename TYPE> TimeInterval FilteredTimeSeriesProperty<TYPE>::nthInter
deltaT = TimeSeriesProperty<TYPE>::nthInterval(n);
} else {
this->applyFilter();
// Throw exception if out of bounds
if (n < 0 || n >= static_cast<int>(this->m_filterIntervals.size())) {
const std::string error("nthInterval(): FilteredTimeSeriesProperty '" + this->name() + "' interval " +
std::to_string(n) + " does not exist");
g_log.debug(error);
throw std::runtime_error(error);
}
deltaT = this->m_filterIntervals[std::size_t(n)];
}

Expand Down Expand Up @@ -405,7 +412,7 @@ Kernel::TimeROI *FilteredTimeSeriesProperty<TYPE>::intersectFilterWithOther(cons
auto roi = new TimeROI(*m_filter.get());
if (other && (!other->useAll()))
roi->update_or_replace_intersection(*other);
return std::move(roi);
return roi;
}

template <typename TYPE> const Kernel::TimeROI &FilteredTimeSeriesProperty<TYPE>::getTimeROI() const {
Expand Down
9 changes: 9 additions & 0 deletions Framework/Kernel/test/LogFilterTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ class LogFilterTest : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(p->nthInterval(4).end_str(),
"2007-Nov-30 16:17:50"); // nth interval changed to use
// previous interval now.

// test out of bounds check given filter applied
auto testFilter = createTestFilter(1);
LogFilter flt(p);
flt.addFilter(*testFilter);
TS_ASSERT_THROWS_EQUALS(flt.data()->nthInterval(5), const std::runtime_error &e, std::string(e.what()),
"nthInterval(): FilteredTimeSeriesProperty 'test' interval 5 does not exist");
TS_ASSERT_THROWS_EQUALS(flt.data()->nthInterval(-1), const std::runtime_error &e, std::string(e.what()),
"nthInterval(): FilteredTimeSeriesProperty 'test' interval -1 does not exist");
}

void testFilterWithTrueAtStart() {
Expand Down
1 change: 1 addition & 0 deletions docs/source/release/v6.13.0/Framework/Bugfixes/39238.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Handled out of bounds error possible when using ``nthTime`` and ``nthInterval`` methods of a ``FilteredTimeSeriesProperty``. This occurred when the argument ``n`` was specified as an invalid index of the time filter intervals vector.