Commit 34ec9ec7 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[regexp] Fix invalid access into empty string

If `out` is empty accessing `out.back()` is invalid.

TBR=yangguo@chromium.org

Bug: chromium:894934
Change-Id: I7286c5b6a9857f1cdb2bcaf383094bee65bac393
Reviewed-on: https://chromium-review.googlesource.com/c/1282565Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56669}
parent f523befa
......@@ -103,7 +103,7 @@ std::string NaiveEscape(const std::string& input, char escaped_char) {
}
// Disallow trailing backslashes as they mess with our naive source string
// concatenation.
if (out.back() == '\\') out.back() = '_';
if (!out.empty() && out.back() == '\\') out.back() = '_';
return out;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment