Skip to content

Commit 2988910

Browse files
authored
Merge pull request #182 from hamishknight/avoid-use-after-move
Avoid a potential use-after-move
2 parents 2960b6f + 74658bd commit 2988910

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/Index/IndexSystem.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,19 @@ class AsyncIndexDelegate : public IndexSystemDelegate {
9898
OutOfDateFileTriggerRef trigger,
9999
bool synchronous) override {
100100
if (synchronous) {
101-
Queue.dispatchSync([&]{
102-
for (auto &other : Others)
103-
other->unitIsOutOfDate(std::move(unitInfo), trigger, true);
104-
});
101+
Queue.dispatchSync(
102+
[this, unitInfo = std::move(unitInfo), trigger = std::move(trigger)] {
103+
for (auto &other : Others)
104+
other->unitIsOutOfDate(unitInfo, trigger, /*synchronous*/ true);
105+
});
105106
return;
106107
}
107108

108-
Queue.dispatch([=]{
109-
for (auto &other : Others)
110-
other->unitIsOutOfDate(std::move(unitInfo), trigger, false);
111-
});
109+
Queue.dispatch(
110+
[this, unitInfo = std::move(unitInfo), trigger = std::move(trigger)] {
111+
for (auto &other : Others)
112+
other->unitIsOutOfDate(unitInfo, trigger, /*synchronous*/ false);
113+
});
112114
}
113115

114116
public:

0 commit comments

Comments
 (0)