GeezerVison is showing github.com — buffer: fix copy() segfault with zero arguments · nodejs/node@5404cbc
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_buffer.cc +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -303,11 +303,11 @@ void Base64Slice(const FunctionCallbackInfo<Value>& args) { |
303 | 303 | void Copy(const FunctionCallbackInfo<Value> &args) { |
304 | 304 | Environment* env = Environment::GetCurrent(args); |
305 | 305 |
|
306 | | - Local<Object> target = args[0]->ToObject(env->isolate()); |
307 | | - |
308 | | - if (!HasInstance(target)) |
| 306 | + if (!HasInstance(args[0])) |
309 | 307 | return env->ThrowTypeError("first arg should be a Buffer"); |
310 | 308 |
|
| 309 | + Local<Object> target = args[0]->ToObject(env->isolate()); |
| 310 | + |
311 | 311 | ARGS_THIS(args.This()) |
312 | 312 | size_t target_length = target->GetIndexedPropertiesExternalArrayDataLength(); |
313 | 313 | char* target_data = static_cast<char*>( |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-buffer.js +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1179,3 +1179,8 @@ var ps = Buffer.poolSize; |
1179 | 1179 | Buffer.poolSize = 0; |
1180 | 1180 | assert.equal(Buffer(1).parent, undefined); |
1181 | 1181 | Buffer.poolSize = ps; |
| 1182 | + |
| 1183 | +// Test Buffer.copy() segfault |
| 1184 | +assert.throws(function() { |
| 1185 | + Buffer(10).copy(); |
| 1186 | +}); |