diff options
| author | swarmer <[email protected]> | 2025-10-22 00:40:56 +0300 |
|---|---|---|
| committer | swarmer <[email protected]> | 2025-10-22 01:00:33 +0300 |
| commit | 30ad3d5b967bb270c8f5a1dcdeb205b23808b4cf (patch) | |
| tree | ad589ee9f8bc8e54411a8e1d5917bfaf2bf59fa3 /util/string/split.cpp | |
| parent | 63b90b2797099da1bf2768b3f897565fb855f75a (diff) | |
StringSplitter: splitting an empty string should always produce exactly one token
Previously, the split operation would produce incorrect results if the bound of the user-provided string overlaps with the address of a default-constructed string. Introduce a sentinel value to ensure that such overlap are no longer possible.
Use additional boolean flag to check for the similar problem in the iterator-based version of algorithm.
commit_hash:6590787dc4c0319375efa3630a7146e31eed5e89
Diffstat (limited to 'util/string/split.cpp')
| -rw-r--r-- | util/string/split.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/util/string/split.cpp b/util/string/split.cpp index 7d26857cc7a..f27be107c76 100644 --- a/util/string/split.cpp +++ b/util/string/split.cpp @@ -22,3 +22,5 @@ size_t Split(const char* ptr, const char* delim, TVector<TString>& values) { size_t Split(const TString& in, const TString& delim, TVector<TString>& res) { return Split(in.data(), delim.data(), res); } + +alignas(wchar32) const char NStringSplitPrivate::SPLITTER_EMPTY_SENTINEL{0}; |
