File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -150,14 +150,14 @@ export class Parser {
150150 this . remainingBufferLength = 0
151151 this . remainingBufferOffset = 0
152152 } else {
153+ this . remainingBufferLength = fullLength - offset
153154 if ( reuseRemainingBuffer ) {
154155 // Adjust the cursors of remainingBuffer
155- this . remainingBufferLength = combinedBufferLength - offset
156- this . remainingBufferOffset += offset
156+ this . remainingBufferOffset = offset
157157 } else {
158- // To avoid side effects, copy the remaining part of the new buffer to remainingBuffer
159- this . remainingBuffer = combinedBuffer . slice ( offset )
160- this . remainingBufferLength = this . remainingBuffer . byteLength
158+ // To avoid side effects, copy the remaining part of the new buffer to remainingBuffer with extra space for next buffer
159+ this . remainingBuffer = Buffer . allocUnsafe ( combinedBufferLength * 2 )
160+ combinedBuffer . copy ( this . remainingBuffer , 0 , offset )
161161 this . remainingBufferOffset = 0
162162 }
163163 }
You can’t perform that action at this time.
0 commit comments