Skip to content
Snippets Groups Projects
Commit 5eabbbd2 authored by Aleksandr Lyapunov's avatar Aleksandr Lyapunov Committed by Kirill Yukhin
Browse files

Fix wrong make_scoped_guard usage

The common pitfall of using a lambda is wrong type of capture -
by value instead of by reference. The simple example is:
  struct sequence_def *new_def = NULL;
  auto def_guard = make_scoped_guard([=] { free(new_def); });
  // initialize new_def
The problem is that the lambda captures pointer by value, that
is NULL and will remain NULL in the lambda while new_def is
successfully initialized in function scope.

The patch fixes the problem above and a couple of similar mistakes.

Fixes #5154
parent 4cf94ef8
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment