From cb306e6b48ddf667380e72d74a405413a7e07e73 Mon Sep 17 00:00:00 2001
From: Dewey Dunnington <dewey@fishandwhistle.net>
Date: Fri, 29 Jul 2022 08:26:34 -0400
Subject: [PATCH] try more explicit capture list to see if that helps the
 valgrind thing

---
 r/src/compute-exec.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/r/src/compute-exec.cpp b/r/src/compute-exec.cpp
index 91d646f0a3c08..9fadfa3ec5840 100644
--- a/r/src/compute-exec.cpp
+++ b/r/src/compute-exec.cpp
@@ -142,7 +142,7 @@ std::shared_ptr<arrow::Table> ExecPlan_read_table(
   auto prepared_plan = ExecPlan_prepare(plan, final_node, sort_options, metadata, head);
 
   auto result = RunWithCapturedRIfPossible<std::shared_ptr<arrow::Table>>(
-      [&]() -> arrow::Result<std::shared_ptr<arrow::Table>> {
+      [prepared_plan]() -> arrow::Result<std::shared_ptr<arrow::Table>> {
         ARROW_RETURN_NOT_OK(prepared_plan.first->StartProducing());
         return prepared_plan.second->ToTable();
       });
@@ -273,7 +273,7 @@ void ExecPlan_Write(
 
   StopIfNotOk(plan->Validate());
 
-  arrow::Status result = RunWithCapturedRIfPossibleVoid([&]() {
+  arrow::Status result = RunWithCapturedRIfPossibleVoid([&plan]() {
     RETURN_NOT_OK(plan->StartProducing());
     RETURN_NOT_OK(plan->finished().status());
     return arrow::Status::OK();