Fix out-of-bound access

This commit is contained in:
Milo Yip 2016-01-29 10:53:33 +08:00
parent ea62c64add
commit 4ce000b9f5

View File

@ -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() {