Skip to content

Commit

Permalink
Fix ASan issues in RegexSplit introduced by patch
Browse files Browse the repository at this point in the history
Bug: 1173328
Change-Id: Ibccd7aae13ff0e9dd343d62af56f39b6b71a5c28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2729167
Reviewed-by: Michael Crouse <mcrouse@chromium.org>
Commit-Queue: Sophie Chang <sophiechang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#859065}
  • Loading branch information
Sophie Chang authored and Chromium LUCI CQ committed Mar 2, 2021
1 parent 18eecd4 commit 7760ad5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ index aa17d772dcfc..3165412d5088 100644
if (should_include_delim) {
// If desired, include the deliminator as a token.
- tokens->push_back(extracted_delim_token);
+ tokens->push_back(extracted_delim_token.as_string());
+ tokens->push_back(absl:string_view(extracted_delim_token.data(),
+ extracted_delim_token.size()));
// Mark the end of the token at the end of the beginning of the delimiter.
begin_offsets->push_back(extracted_delim_token.data() - input.begin());
end_offsets->push_back(extracted_delim_token.data() +
Expand All @@ -40,7 +41,7 @@ index aa17d772dcfc..3165412d5088 100644
// Close the last token.
if (!leftover.empty()) {
- tokens->push_back(leftover);
+ tokens->push_back(leftover.as_string());
+ tokens->push_back(absl::string_view(leftover.data(), leftover.size()));
begin_offsets->push_back(leftover.data() - input.begin());
end_offsets->push_back(leftover.data() + leftover.length() - input.begin());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ void RegexSplitImpl(absl::string_view input,

if (should_include_delim) {
// If desired, include the deliminator as a token.
tokens->push_back(extracted_delim_token.as_string());
tokens->push_back(absl::string_view(extracted_delim_token.data(),
extracted_delim_token.size()));
// Mark the end of the token at the end of the beginning of the delimiter.
begin_offsets->push_back(extracted_delim_token.data() - input.begin());
end_offsets->push_back(extracted_delim_token.data() +
Expand All @@ -62,7 +63,7 @@ void RegexSplitImpl(absl::string_view input,

// Close the last token.
if (!leftover.empty()) {
tokens->push_back(leftover.as_string());
tokens->push_back(absl::string_view(leftover.data(), leftover.size()));
begin_offsets->push_back(leftover.data() - input.begin());
end_offsets->push_back(leftover.data() + leftover.length() - input.begin());
}
Expand Down

0 comments on commit 7760ad5

Please sign in to comment.