makeFastBuffer should not segfault but rather throw on non-buffer
This commit is contained in:
parent
f4e69e44ff
commit
5e409c2f1a
@ -679,6 +679,11 @@ Handle<Value> Buffer::ByteLength(const Arguments &args) {
|
||||
Handle<Value> Buffer::MakeFastBuffer(const Arguments &args) {
|
||||
HandleScope scope;
|
||||
|
||||
if (!Buffer::HasInstance(args[0])) {
|
||||
return ThrowException(Exception::TypeError(String::New(
|
||||
"First argument must be a Buffer")));
|
||||
}
|
||||
|
||||
Buffer *buffer = ObjectWrap::Unwrap<Buffer>(args[0]->ToObject());
|
||||
Local<Object> fast_buffer = args[1]->ToObject();;
|
||||
uint32_t offset = args[2]->Uint32Value();
|
||||
|
@ -520,3 +520,7 @@ assert.equal(0xee, b[0]);
|
||||
assert.equal(0xad, b[1]);
|
||||
assert.equal(0xbe, b[2]);
|
||||
assert.equal(0xef, b[3]);
|
||||
|
||||
|
||||
// This should not segfault the program.
|
||||
new Buffer('"pong"', 0, 6, 8031, '127.0.0.1')
|
||||
|
Loading…
x
Reference in New Issue
Block a user