Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Fix use-after-free in solver status callback (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
shueja authored Jun 19, 2024
1 parent bdebc87 commit 992f140
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/optimization/algorithms/SwerveDiscreteOptimal.inc
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ SwerveDiscreteOptimal<Expr, Opti>::SwerveDiscreteOptimal(
const SwervePath& path, const std::vector<size_t>& N,
const Solution& initialGuess, int64_t handle)
: path(path), N(N) {
// force the initial call
auto lastFrameTime = std::chrono::steady_clock::now();

opti.AddIntermediateCallback([=, this, &lastFrameTime]() {
opti.AddIntermediateCallback([=, this] {
using namespace std::chrono_literals;

static auto lastFrameTime = std::chrono::steady_clock::now();
auto now = std::chrono::steady_clock::now();
constexpr int fps = 60;
constexpr std::chrono::duration<double> timePerFrame{1.0 / fps};
Expand Down

0 comments on commit 992f140

Please sign in to comment.