Commit 4ce000b9 authored by Milo Yip's avatar Milo Yip

Fix out-of-bound access

parent ea62c64a
...@@ -143,7 +143,12 @@ private: ...@@ -143,7 +143,12 @@ private:
public: public:
DecodedStream(SourceStream& ss) : ss_(ss), codepoint_() { Decode(); } DecodedStream(SourceStream& ss) : ss_(ss), codepoint_() { Decode(); }
unsigned Peek() { return codepoint_; } unsigned Peek() { return codepoint_; }
unsigned Take() { unsigned c = codepoint_; Decode(); return c; } unsigned Take() {
unsigned c = codepoint_;
if (c) // No further decoding when '\0'
Decode();
return c;
}
private: private:
void Decode() { void Decode() {
......
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