diff --git a/rmw_zenoh_cpp/src/rmw_zenoh.cpp b/rmw_zenoh_cpp/src/rmw_zenoh.cpp index 1635eded..4e66fb25 100644 --- a/rmw_zenoh_cpp/src/rmw_zenoh.cpp +++ b/rmw_zenoh_cpp/src/rmw_zenoh.cpp @@ -879,7 +879,7 @@ rmw_publish( } }); auto free_msg_bytes = rcpputils::make_scope_exit( - [msg_bytes, allocator, &shmbuf]() { + [&msg_bytes, allocator, &shmbuf]() { if (msg_bytes && !shmbuf.has_value()) { allocator->deallocate(msg_bytes, allocator->state); }