diff --git a/include/glim/util/concurrent_vector.hpp b/include/glim/util/concurrent_vector.hpp index 7faebb1f..5985e1e6 100644 --- a/include/glim/util/concurrent_vector.hpp +++ b/include/glim/util/concurrent_vector.hpp @@ -134,6 +134,10 @@ class ConcurrentVector { std::vector get_and_clear(int num_max) { std::vector buffer; std::lock_guard lock(mutex); + if (values.empty()) { + return buffer; + } + if (values.size() <= num_max) { buffer.assign(values.begin(), values.end()); values.clear(); diff --git a/include/glim/util/interpolation_helper.hpp b/include/glim/util/interpolation_helper.hpp index 1ca3cbe8..ef9d5f38 100644 --- a/include/glim/util/interpolation_helper.hpp +++ b/include/glim/util/interpolation_helper.hpp @@ -32,10 +32,16 @@ class InterpolationHelper { InterpolationHelperResult find(const double stamp, StampedValue* left_ptr, StampedValue* right_ptr, int* remove_cursor_ptr) const { if (values.empty() || values.back().first < stamp) { + if (!values.empty() && left_ptr) { + *left_ptr = values.back(); + } return InterpolationHelperResult::WAITING; } if (values.front().first > stamp) { + if (right_ptr) { + *right_ptr = values.front(); + } return InterpolationHelperResult::FAILURE; }