summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--js/src/frontend/TokenStream.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
index 619285090..186b7a8ab 100644
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -225,8 +225,13 @@ TokenStream::SourceCoords::add(uint32_t lineNum, uint32_t lineStartOffset)
// only if lineStartOffsets_.append succeeds, to keep sentinel.
// Otherwise return false to tell TokenStream about OOM.
uint32_t maxPtr = MAX_PTR;
- if (!lineStartOffsets_.append(maxPtr))
+ if (!lineStartOffsets_.append(maxPtr)) {
+ static_assert(mozilla::IsSame<decltype(lineStartOffsets_.allocPolicy()),
+ TempAllocPolicy&>::value,
+ "this function's caller depends on it reporting an "
+ "error on failure, as TempAllocPolicy ensures");
return false;
+ }
lineStartOffsets_[lineIndex] = lineStartOffset;
} else {
@@ -557,7 +562,6 @@ TokenStream::advance(size_t position)
lookahead = 0;
if (flags.hitOOM) {
- error(JSMSG_OUT_OF_MEMORY);
return false;
}
@@ -1876,8 +1880,9 @@ TokenStream::getTokenInternal(TokenKind* ttp, Modifier modifier)
MOZ_CRASH("should have jumped to |out| or |error|");
out:
- if (flags.hitOOM)
- return reportError(JSMSG_OUT_OF_MEMORY);
+ if (flags.hitOOM) {
+ return false;
+ }
flags.isDirtyLine = true;
tp->pos.end = userbuf.offset();
@@ -1893,8 +1898,9 @@ TokenStream::getTokenInternal(TokenKind* ttp, Modifier modifier)
return true;
error:
- if (flags.hitOOM)
- return reportError(JSMSG_OUT_OF_MEMORY);
+ if (flags.hitOOM) {
+ return false;
+ }
flags.isDirtyLine = true;
tp->pos.end = userbuf.offset();