File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -189,9 +189,14 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
189
189
190
190
int StreamBase::WriteBuffer (const FunctionCallbackInfo<Value>& args) {
191
191
CHECK (args[0 ]->IsObject ());
192
- CHECK ( Buffer::HasInstance (args[ 1 ]));
192
+
193
193
Environment* env = Environment::GetCurrent (args);
194
194
195
+ if (!args[1 ]->IsUint8Array ()) {
196
+ env->ThrowTypeError (" Second argument must be a buffer" );
197
+ return 0 ;
198
+ }
199
+
195
200
Local<Object> req_wrap_obj = args[0 ].As <Object>();
196
201
const char * data = Buffer::Data (args[1 ]);
197
202
size_t length = Buffer::Length (args[1 ]);
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+ const net = require ( 'net' ) ;
5
+
6
+ const server = net . createServer ( ) . listen ( 0 , common . mustCall ( ( ) => {
7
+ const client = net . connect ( server . address ( ) . port , common . mustCall ( ( ) => {
8
+ assert . throws ( ( ) => {
9
+ client . write ( 'broken' , 'buffer' ) ;
10
+ } , / ^ T y p e E r r o r : S e c o n d a r g u m e n t m u s t b e a b u f f e r $ / ) ;
11
+ client . destroy ( ) ;
12
+ server . close ( ) ;
13
+ } ) ) ;
14
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments