Skip to content

Commit

Permalink
fix: Heap corruption when reducing reducing num points in Line.
Browse files Browse the repository at this point in the history
  • Loading branch information
3-Sigma-Chris authored and mtytel committed Feb 4, 2025
1 parent 84e0ecd commit 6556a52
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions visage_graphics/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ namespace visage {
values = std::make_unique<float[]>(points);

if (num_points) {
std::memcpy(x.get(), old_x.get(), num_points * sizeof(float));
std::memcpy(y.get(), old_y.get(), num_points * sizeof(float));
std::memcpy(values.get(), old_values.get(), num_points * sizeof(float));
const int pointsToCopy = std::min(num_points, points);
std::memcpy(x.get(), old_x.get(), pointsToCopy * sizeof(float));
std::memcpy(y.get(), old_y.get(), pointsToCopy * sizeof(float));
std::memcpy(values.get(), old_values.get(), pointsToCopy * sizeof(float));
}
}

Expand Down

0 comments on commit 6556a52

Please sign in to comment.