Bug 1437004 - Fixing null string behavior in BinAST tokenizer;r?arai,jorendorff
MozReview-Commit-ID: AH91BMcoZsB
--- a/js/src/frontend/BinTokenReaderTester.cpp
+++ b/js/src/frontend/BinTokenReaderTester.cpp
@@ -195,33 +195,30 @@ BinTokenReaderTester::readMaybeChars(May
// 2. Reject if we can't read
if (current_ + byteLen < current_) // Check for overflows
return raiseError("Arithmetics overflow: string is too long");
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;
return true;
}
bool
BinTokenReaderTester::readChars(Chars& out)