summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2015-02-16 14:13:53 -0700
committerTrevor Norris <trev.norris@gmail.com>2015-02-16 14:13:53 -0700
commita35ba2f67dfcdf21b87f4326c6d67150f40224b6 (patch)
treec6c2987007e5045ba44d4d49c1b4499428c1b8e7
parent6c3647c38d73f729ce85633a0440cd939d93dea2 (diff)
downloadnode-a35ba2f67dfcdf21b87f4326c6d67150f40224b6.tar.gz
buffer: fix pool offset adjustment
If the Buffer allocation isn't a slice then there's no need to adjust the pool offset after realloc'ing the space available. Fixes: 6462519 "buffer, doc: misc. fix and cleanup"
-rw-r--r--lib/buffer.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index e5588963d..9b43882e5 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -104,7 +104,9 @@ function Buffer(subject, encoding) {
var prevLen = this.length;
this.length = len;
truncate(this, this.length);
- poolOffset -= (prevLen - len);
+ // Only need to readjust the poolOffset if the allocation is a slice.
+ if (this.parent != undefined)
+ poolOffset -= (prevLen - len);
}
} else if (util.isBuffer(subject)) {