-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream_wrap: error if stream has StringDecoder
If `.setEncoding` was called on input stream - all emitted `data` will be `String`s instances, not `Buffer`s. This is unacceptable for `StreamWrap`, and should not lead to the crash. Fix: #3970 PR-URL: #4031 Reviewed-By: Colin Ihrig <[email protected]>
- Loading branch information
Showing
2 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const StreamWrap = require('_stream_wrap'); | ||
const Duplex = require('stream').Duplex; | ||
|
||
const stream = new Duplex({ | ||
read: function() { | ||
}, | ||
write: function() { | ||
} | ||
}); | ||
|
||
stream.setEncoding('ascii'); | ||
|
||
const wrap = new StreamWrap(stream); | ||
|
||
wrap.on('error', common.mustCall(function(err) { | ||
assert(/StringDecoder/.test(err.message)); | ||
})); | ||
|
||
stream.push('ohai'); |