Move ProjFS enumerator into getEnumerationData callback

Summary:
Even though we only need the Enumeration in the future's callback, if we don't
move the Enumerator it can get dereferenced while we're awaiting the future
returned by prepareEnumeration().

Reviewed By: xavierd

Differential Revision: D44770398

fbshipit-source-id: a9fc91c0766b4a9f43f566887d714cbde66b1cf3
This commit is contained in:
Mark Shroyer 2023-04-06 19:09:05 -07:00 committed by Facebook GitHub Bot
parent 7afc5962ef
commit b260939c66

View File

@ -490,8 +490,10 @@ HRESULT PrjfsChannelInner::getEnumerationData(
context->startRequest(getStats().copy(), stat, requestWatch);
return enumerator->prepareEnumeration().thenValue(
[buffer, context = std::move(context)](
std::shared_ptr<Enumeration> enumeration) {
[buffer,
context = std::move(context),
enumerator =
std::move(enumerator)](std::shared_ptr<Enumeration> enumeration) {
bool added = false;
for (auto optEntry = enumeration->getCurrent(); optEntry.has_value();
optEntry = enumeration->getNext()) {