summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2014-09-23 13:19:31 -0700
committerTrevor Norris <trev.norris@gmail.com>2014-09-23 17:10:36 -0700
commit7c3c51b8ff3d41a2714e6d3a1379f2357b5bebc7 (patch)
treecb13135da7d6bdd3b672bbabbecf52d1e739fe2a
parent7fd35e6ea43ece7ef40d50820a80d798eceaa362 (diff)
downloadnodejs-7c3c51b8ff3d41a2714e6d3a1379f2357b5bebc7.tar.gz
nodejs-7c3c51b8ff3d41a2714e6d3a1379f2357b5bebc7.tar.bz2
nodejs-7c3c51b8ff3d41a2714e6d3a1379f2357b5bebc7.zip
buffer: fix map and set parent to undefinedupstream/0.12.0
In 4c9b30d removal of the prototype attributes meant NativeBuffer() no longer had the same object map as Buffer(). By now setting the same properties in the same order both constructors will produce the same map. The same commit changed "parent" from undefined to null. This caused a failure in Buffer#slice() where it was checked if parent === undefined. Causing the incorrect parent to be set. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
-rw-r--r--lib/buffer.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index adb551a9e..ed1591584 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -66,7 +66,7 @@ function Buffer(subject, encoding) {
'size: 0x' + kMaxLength.toString(16) + ' bytes');
}
- this.parent = null;
+ this.parent = undefined;
if (this.length <= (Buffer.poolSize >>> 1) && this.length > 0) {
if (this.length > poolSize - poolOffset)
createPool();
@@ -118,7 +118,9 @@ function SlowBuffer(length) {
// Objects created in C++. Significantly faster than calling the Buffer
// function.
function NativeBuffer(length) {
- this.length = length;
+ this.length = length >>> 0;
+ // Set this to keep the object map the same.
+ this.parent = undefined;
}
NativeBuffer.prototype = Buffer.prototype;