Skip to content

Commit

Permalink
Found a bug by asan.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorstenhater committed Sep 25, 2024
1 parent cd7448c commit 9b1ca35
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions arbor/util/piecewise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,16 +429,18 @@ struct pw_elements {
auto ei = begin(values);
auto ee = end(values);

if (ei == ee) { // empty case
// clean-up
clear();

// empty case
if (ei == ee) {
if (vi != ve) throw std::runtime_error{"Vertices and values need to have same length; values too long."};
clear();
return;
}
clear();
if (vi == ve) throw std::runtime_error{"Vertices and values need to have same length; values too short."};

reserve(vertices.size());
double left = *vi++;
if (vi == ve) throw std::runtime_error{"Vertices and values need to have same length; values too short."};
double right = *vi++;
push_back(left, right, *ei++);

Expand Down

0 comments on commit 9b1ca35

Please sign in to comment.