diff options
| author | ilnurkh <[email protected]> | 2025-09-05 13:47:22 +0300 |
|---|---|---|
| committer | ilnurkh <[email protected]> | 2025-09-05 14:30:31 +0300 |
| commit | 40046403f56864f7d8bf314ef1c15ff6221cd54a (patch) | |
| tree | eb4dbc8b37d402cc2c4b8418acea54bdabaa2aa0 /contrib/libs/jinja2cpp/src | |
| parent | 87f9713a7ed18e40be81e13002050847a4c21a0d (diff) | |
fix coredump by select + first
commit_hash:351845650cfb323aceb7b5ee0157adaba578705a
Diffstat (limited to 'contrib/libs/jinja2cpp/src')
| -rw-r--r-- | contrib/libs/jinja2cpp/src/filters.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/libs/jinja2cpp/src/filters.cpp b/contrib/libs/jinja2cpp/src/filters.cpp index 5e0725be964..ff85f386b22 100644 --- a/contrib/libs/jinja2cpp/src/filters.cpp +++ b/contrib/libs/jinja2cpp/src/filters.cpp @@ -481,7 +481,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte switch (m_mode) { case FirstItemMode: - if (listSize) + if (listSize && *listSize > 0) result = list.GetValueByIndex(0); else { @@ -491,7 +491,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte } break; case LastItemMode: - if (listSize) + if (listSize && *listSize > 0) result = list.GetValueByIndex(listSize.value() - 1); else { @@ -502,7 +502,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte } break; case LengthMode: - if (listSize) + if (listSize && *listSize > 0) result = static_cast<int64_t>(listSize.value()); else result = static_cast<int64_t>(std::distance(list.begin(), list.end())); @@ -511,7 +511,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte { std::random_device rd; std::mt19937 gen(rd()); - if (listSize) + if (listSize && *listSize > 0) { std::uniform_int_distribution<> dis(0, static_cast<int>(listSize.value()) - 1); result = list.GetValueByIndex(dis(gen)); @@ -548,7 +548,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte } case ReverseMode: { - if (listSize) + if (listSize && *listSize > 0) { auto size = listSize.value(); InternalValueList resultList(size); |
