diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-02-29 19:09:10 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-02-29 19:09:10 +1100 |
commit | 0b4119ce125792d55da6a5bdd48d3cbfb4953e5a (patch) | |
tree | 2cd0699a24586eb1635024a232b162423f65b662 /source/core/StarDirectives.cpp | |
parent | 7ff287511d8e5d18260202d80d6b8c68368bc5bc (diff) |
Fix possible Unicode exception in Directives parsing
Diffstat (limited to 'source/core/StarDirectives.cpp')
-rw-r--r-- | source/core/StarDirectives.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/source/core/StarDirectives.cpp b/source/core/StarDirectives.cpp index 5d5266f..245c8c0 100644 --- a/source/core/StarDirectives.cpp +++ b/source/core/StarDirectives.cpp @@ -124,7 +124,7 @@ void Directives::parse(String&& directives) { return; } - List<Entry> newList; + List<Entry> entries; StringView view(directives); StringView prefix = ""; view.forEachSplitView("?", [&](StringView split, size_t beg, size_t end) { @@ -132,7 +132,7 @@ void Directives::parse(String&& directives) { if (beg == 0) { try { ImageOperation operation = imageOperationFromString(split); - newList.emplace_back(std::move(operation), beg, end); + entries.emplace_back(std::move(operation), beg, end); } catch (StarException const& e) { prefix = split; @@ -141,18 +141,18 @@ void Directives::parse(String&& directives) { } else { ImageOperation operation = NullImageOperation(); - newList.emplace_back(std::move(operation), beg, end); + entries.emplace_back(std::move(operation), beg, end); } } - }); + }); - if (newList.empty() && !prefix.empty()) { + if (entries.empty() && !prefix.empty()) { shared.reset(); return; } - shared = std::make_shared<Shared const>(std::move(newList), std::move(directives), prefix); - if (view.size() < 1000) { // Pre-load short enough directives + shared = std::make_shared<Shared const>(std::move(entries), std::move(directives), prefix); + if (view.utf8().size() < 1000) { // Pre-load short enough directives for (auto& entry : shared->entries) entry.loadOperation(*shared); } |