fix infinite loop in readUnknownSym

This commit is contained in:
tophf 2022-06-26 18:13:13 +03:00
parent 91501cce19
commit 6e0cfb7d0f

View File

@ -3149,11 +3149,11 @@ self.parserlib = (() => {
readUnknownSym() { readUnknownSym() {
const reader = this._reader; const reader = this._reader;
const prelude = []; let prelude = '';
let block; let block;
while (true) { while (true) {
if (reader.eof()) this.throwUnexpected(); let c = reader.peek();
const c = reader.peek(); if (!c) this.throwUnexpected();
if (c === '{') { if (c === '{') {
block = this.readDeclValue({stopOn: ''}); block = this.readDeclValue({stopOn: ''});
break; break;
@ -3161,10 +3161,12 @@ self.parserlib = (() => {
reader.read(); reader.read();
break; break;
} else { } else {
prelude.push(this.readDeclValue({omitComments: true, stopOn: ';{'})); c = this.readDeclValue({omitComments: true, stopOn: ';{}'});
if (!c) break;
prelude += c;
} }
} }
return {prelude, block}; return {prelude: prelude.replace(/^\s+/, ''), block};
} }
} }