Skip to content

Commit

Permalink
Update filters.cpp
Browse files Browse the repository at this point in the history
Fixing missing life rage protection for the reverse filter.
  • Loading branch information
jferreyra-sc authored and rmorozov committed Feb 22, 2024
1 parent 98f7cb2 commit c5e0a3b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,12 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte
auto size = listSize.value();
InternalValueList resultList(size);
for (std::size_t n = 0; n < size; ++n)
resultList[size - n - 1] = list.GetValueByIndex(n);
{
auto resultVal = InternalValue(std::move( list.GetValueByIndex(n) ));
if (baseVal.ShouldExtendLifetime())
resultVal.SetParentData(baseVal);
resultList[size - n - 1] = std::move(resultVal);
}
result = ListAdapter::CreateAdapter(std::move(resultList));
}
else
Expand All @@ -562,7 +567,12 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte
auto it = list.begin();
auto end = list.end();
for (; it != end; ++it)
resultList.push_back(*it);
{
auto resultVal = InternalValue(std::move( *it ));
if (baseVal.ShouldExtendLifetime())
resultVal.SetParentData(baseVal);
resultList.push_back(std::move(resultVal));
}

std::reverse(resultList.begin(), resultList.end());
result = ListAdapter::CreateAdapter(std::move(resultList));
Expand Down

0 comments on commit c5e0a3b

Please sign in to comment.