Use parent SlowBuffer, if any, when Buffer is sliced
Closes #3416 Closes #3477
This commit is contained in:
parent
81a889fd88
commit
57d53a47e8
@ -210,8 +210,12 @@ function Buffer(subject, encoding, offset) {
|
||||
|
||||
// Are we slicing?
|
||||
if (typeof offset === 'number') {
|
||||
if (!Buffer.isBuffer(subject)) {
|
||||
throw new Error('First argument must be a Buffer when slicing');
|
||||
}
|
||||
|
||||
this.length = coerce(encoding);
|
||||
this.parent = subject;
|
||||
this.parent = subject.parent ? subject.parent : subject;
|
||||
this.offset = offset;
|
||||
} else {
|
||||
// Find the length
|
||||
|
@ -724,3 +724,6 @@ var a = Buffer(3);
|
||||
var b = Buffer('xxx');
|
||||
a.write('aaaaaaaa', 'base64');
|
||||
assert.equal(b.toString(), 'xxx');
|
||||
|
||||
// issue GH-3416
|
||||
Buffer(Buffer(0), 0, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user