summaryrefslogtreecommitdiff
path: root/cmds/incidentd/src/Section.cpp
diff options
context:
space:
mode:
authorMike Ma <yanmin@google.com>2020-06-05 00:51:22 -0700
committerMike Ma <yanmin@google.com>2020-06-05 00:51:22 -0700
commit4686c24f53c20280026a8c22169c8a2daa9d4ecf (patch)
tree446c5584445d13b51944ce99368ed3ae6036c5bb /cmds/incidentd/src/Section.cpp
parentbb9ea4e1fa38a9448589b4521aff06ec05ad1567 (diff)
Fix a lambda capture problem in TextDumpsysSection
The [&] capture does not handle smart pointers (unique_ptr, unique_fd etc) well, which lead to leaked pointers. Fix by explicitly move the smart pointers. Bug: 158097879 Test: Build, flash and take an incident report. Verify no crash Change-Id: I5150aa3dddf9d59c1c9d6d32370370e8cde23946
Diffstat (limited to 'cmds/incidentd/src/Section.cpp')
-rw-r--r--cmds/incidentd/src/Section.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp
index 61e5eb07130c..33e764988b75 100644
--- a/cmds/incidentd/src/Section.cpp
+++ b/cmds/incidentd/src/Section.cpp
@@ -477,14 +477,15 @@ status_t TextDumpsysSection::Execute(ReportWriter* writer) const {
// Run dumping thread
const uint64_t start = Nanotime();
- std::thread worker([&]() {
+ std::thread worker([write_fd = std::move(dumpPipe.writeFd()), service = std::move(service),
+ this]() mutable {
// Don't crash the service if writing to a closed pipe (may happen if dumping times out)
signal(SIGPIPE, sigpipe_handler);
- status_t err = service->dump(dumpPipe.writeFd().get(), mArgs);
+ status_t err = service->dump(write_fd.get(), this->mArgs);
if (err != OK) {
ALOGW("[%s] dump thread failed. Error: %s", this->name.string(), strerror(-err));
}
- dumpPipe.writeFd().reset();
+ write_fd.reset();
});
// Collect dump content