diff options
author | Gil Pedersen <git@gpost.dk> | 2013-03-14 14:01:14 +0100 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-03-14 16:13:10 -0700 |
commit | e8f80bf479d79bcd3c8bff7fba70aea483e66449 (patch) | |
tree | 7eaa9e752fb32e4a3937cc24d64beed396ff241e /lib | |
parent | 1f53cfdeae5549a0ecacbd8cd89d60d4faf17768 (diff) | |
download | android-node-v8-e8f80bf479d79bcd3c8bff7fba70aea483e66449.tar.gz android-node-v8-e8f80bf479d79bcd3c8bff7fba70aea483e66449.tar.bz2 android-node-v8-e8f80bf479d79bcd3c8bff7fba70aea483e66449.zip |
stream: Never call decoder.end() multiple times
Updated version that does what it says without assigning state.decoder.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_stream_readable.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index b09694c071..ad0a783985 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -342,14 +342,14 @@ function chunkInvalid(state, chunk) { function onEofChunk(stream, state) { - state.ended = true; - if (state.decoder) { + if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) { state.buffer.push(chunk); state.length += state.objectMode ? 1 : chunk.length; } } + state.ended = true; // if we've ended and we have some data left, then emit // 'readable' now to make sure it gets picked up. @@ -733,12 +733,12 @@ Readable.prototype.wrap = function(stream) { var self = this; stream.on('end', function() { - state.ended = true; - if (state.decoder) { + if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) self.push(chunk); } + state.ended = true; self.push(null); }); |