Avoid undefined behavior from out-of-range access. NFC.

This commit is contained in:
Ryan Pavlik 2019-08-21 13:01:50 -05:00 committed by whitequark
parent b8ee0e941b
commit bedea1ef3c

View File

@ -214,7 +214,7 @@ class ReadUTF8 {
public:
ReadUTF8(const std::string &str) : str(str) {}
utf8_iterator begin() const { return utf8_iterator(&str[0]); }
utf8_iterator end() const { return utf8_iterator(&str[str.length()]); }
utf8_iterator end() const { return utf8_iterator(&str[0] + str.length()); }
};