Skip to content

Commit

Permalink
fix: catch errors in demuxers
Browse files Browse the repository at this point in the history
  • Loading branch information
amishshah committed Jun 12, 2021
1 parent 452505f commit f6fcaad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/core/WebmBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ class WebmBaseDemuxer extends Transform {
this._skipUntil = null;
} else if (this._skipUntil) {
this._count += chunk.length;
return done();
done();
return;
}
let result;
while (result !== TOO_SHORT) {
result = this._readTag(chunk, offset);
try {
result = this._readTag(chunk, offset);
} catch (error) {
this.emit('error', error);
return;
}
if (result === TOO_SHORT) break;
if (result._skipUntil) {
this._skipUntil = result._skipUntil;
Expand All @@ -53,7 +59,8 @@ class WebmBaseDemuxer extends Transform {
}
this._count += offset;
this._remainder = chunk.slice(offset);
return done();
done();
return;
}

/**
Expand Down
13 changes: 9 additions & 4 deletions src/opus/OggDemuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ class OggDemuxer extends Transform {
this._remainder = null;
}

while (chunk) {
const result = this._readPage(chunk);
if (result) chunk = result;
else break;
try {
while (chunk) {
const result = this._readPage(chunk);
if (result) chunk = result;
else break;
}
} catch (error) {
this.emit('error', error);
return;
}
this._remainder = chunk;
done();
Expand Down

0 comments on commit f6fcaad

Please sign in to comment.