File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -312,13 +312,22 @@ export default class Stream {
312
312
}
313
313
314
314
readSingleBuffer ( length ) {
315
- let result = this . list . first . subarray ( this . localOffset , length ) ;
315
+ if ( ! this . available ( 1 ) ) {
316
+ throw new UnderflowError ;
317
+ }
318
+
319
+ let result = this . list . first . subarray ( this . localOffset , this . localOffset + length ) ;
316
320
this . advance ( result . length ) ;
317
321
return result ;
318
322
}
319
323
320
324
peekSingleBuffer ( offset , length ) {
321
- let result = this . list . first . subarray ( this . localOffset + offset , length ) ;
325
+ if ( ! this . available ( offset + 1 ) ) {
326
+ throw new UnderflowError ;
327
+ }
328
+
329
+ offset += this . localOffset ;
330
+ let result = this . list . first . subarray ( offset , offset + length ) ;
322
331
return result ;
323
332
}
324
333
You can’t perform that action at this time.
0 commit comments