Bug 1437004 - Fixing null string behavior in BinAST tokenizer;r=arai,jorendorff

MozReview-Commit-ID: AH91BMcoZsB

--HG--
extra : rebase_source : 4ff060e0443d734ff2be8835a29e6d2716b20b4f
This commit is contained in:
David Teller 2018-02-21 16:27:22 +01:00
parent 2a14a7fb36
commit f4523820b7

View File

@ -200,23 +200,20 @@ BinTokenReaderTester::readMaybeChars(Maybe<Chars>& out)
if (current_ + byteLen > stop_)
return raiseError("Not enough bytes to read chars");
// 3. Check null string (no allocation)
if (byteLen == 2 && *current_ == 255 && *(current_ + 1) == 0) {
// Special case: null string.
// 3. Special case: null string.
out = Nothing();
current_ += byteLen;
return true;
} else {
// 4. Other strings (bytes are copied)
out.emplace(cx_);
if (!out->resize(byteLen)) {
ReportOutOfMemory(cx_);
return false;
}
PodCopy(out->begin(), current_, byteLen);
}
// 4. Other strings (bytes are copied)
out.emplace(cx_);
if (!out->resize(byteLen)) {
ReportOutOfMemory(cx_);
return false;
}
PodCopy(out->begin(), current_, byteLen);
current_ += byteLen;
if (!readConst("</string>"))
return false;