Skip to content

Commit 600fa46

Browse files
committed
fix(spline): check interpolator initialization before accessing data in operator()
1 parent a85b6c1 commit 600fa46

File tree

1 file changed

+5
-5
lines changed
  • cxx/include/pyinterp/math/interpolate/bivariate

1 file changed

+5
-5
lines changed

cxx/include/pyinterp/math/interpolate/bivariate/spline.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ class Spline : public BivariateBase<T> {
5656
///
5757
/// @throws std::runtime_error if grid is empty
5858
[[nodiscard]] auto operator()(const T& x, const T& y) -> T final {
59-
const auto& xa = this->xa();
60-
const auto& ya = this->ya();
61-
const auto& za = this->za();
62-
63-
// Check if interpolator was properly initialized
59+
// Check if interpolator was properly initialized BEFORE accessing data
6460
if (!this->is_valid()) [[unlikely]] {
6561
return math::Fill<T>::value();
6662
}
6763

64+
const auto& xa = this->xa();
65+
const auto& ya = this->ya();
66+
const auto& za = this->za();
67+
6868
return interpolate_y_then_x(xa, ya, za, x, y);
6969
}
7070

0 commit comments

Comments
 (0)