buffer: fix pool offset adjustment
authorTrevor Norris <trev.norris@gmail.com>
Mon, 16 Feb 2015 21:09:50 +0000 (14:09 -0700)
committerTrevor Norris <trev.norris@gmail.com>
Mon, 16 Feb 2015 21:09:50 +0000 (14:09 -0700)
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"

lib/buffer.js

index 3e69090..bb30475 100644 (file)
@@ -84,7 +84,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 (subject instanceof Buffer) {