From a02e4935bd84712df92e0c4f7b608cbc8bc0f13b Mon Sep 17 00:00:00 2001 From: danakj Date: Thu, 25 Jan 2024 18:02:30 -0500 Subject: [PATCH] Avoid assuming string_view iterators are char* This assumption is non-portable and prevents Chromium from using bounded iterators in libc++. Bug: chromium: 1519908 Change-Id: Iafe6639ef3bc896d6fa4fb3ceb7ac0b546363017 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5237292 Reviewed-by: Mark Mentovai Commit-Queue: danakj --- util/mach/symbolic_constants_mach.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/util/mach/symbolic_constants_mach.cc b/util/mach/symbolic_constants_mach.cc index eb90bd78..7a591901 100644 --- a/util/mach/symbolic_constants_mach.cc +++ b/util/mach/symbolic_constants_mach.cc @@ -299,14 +299,11 @@ bool StringToExceptionMask(const base::StringPiece& string, size_t pos = -1; do { ++pos; - const char* substring_begin = string.begin() + pos; + const size_t start = pos; pos = string.find('|', pos); - const char* substring_end = (pos == base::StringPiece::npos) - ? string.end() - : (string.begin() + pos); - base::StringPiece substring = string.substr( - substring_begin - string.begin(), substring_end - substring_begin); - + base::StringPiece substring = (pos == base::StringPiece::npos) + ? string.substr(start) + : string.substr(start, pos - start); exception_mask_t temp_mask; if (!StringToExceptionMask(substring, options, &temp_mask)) { return false;