Bug 1242772 - Baldr: fix unterminated string literal (r=bbouvier)

This commit is contained in:
Luke Wagner 2016-01-26 13:05:01 -06:00
parent 78c2d83bb7
commit 3416300355
2 changed files with 11 additions and 8 deletions

View File

@ -408,9 +408,11 @@ class WasmTokenStream
const char16_t* begin = cur_++;
switch (*begin) {
case '"':
while (cur_ != end_ && *cur_ != '"')
cur_++;
return WasmToken(WasmToken::Text, begin, ++cur_);
do {
if (cur_ == end_)
return fail(begin);
} while (*cur_++ != '"');
return WasmToken(WasmToken::Text, begin, cur_);
case '$':
while (cur_ != end_ && IsNameAfterDollar(*cur_))

View File

@ -5,11 +5,12 @@ if (!this.wasmEval)
var parsingError = /parsing wasm text at/;
assertErrorMessage(() => wasmEvalText(""), Error, parsingError);
assertErrorMessage(() => wasmEvalText("("), Error, parsingError);
assertErrorMessage(() => wasmEvalText("(m"), Error, parsingError);
assertErrorMessage(() => wasmEvalText("(module"), Error, parsingError);
assertErrorMessage(() => wasmEvalText("(moduler"), Error, parsingError);
assertErrorMessage(() => wasmEvalText(''), Error, parsingError);
assertErrorMessage(() => wasmEvalText('('), Error, parsingError);
assertErrorMessage(() => wasmEvalText('(m'), Error, parsingError);
assertErrorMessage(() => wasmEvalText('(module'), Error, parsingError);
assertErrorMessage(() => wasmEvalText('(moduler'), Error, parsingError);
assertErrorMessage(() => wasmEvalText('(module (func) (export "a'), Error, parsingError);
// Note: the s-expression text format is temporary, this file is mostly just to
// hold basic error smoke tests.