Fix incorrect lambda capture leading to crash.

Fixes #1451
2 jobs for release/22.04 in 7 minutes and 37 seconds (queued for 4 seconds)