Browse Source

buffer: align chunks on 8-byte boundary

When slicing global pool - ensure that the underlying buffer's data ptr
is 8-byte alignment to do not ruin expectations of 3rd party C++ addons.

NOTE: 0.10 node.js always returned aligned pointers and v0.12 should do
this too for compatibility.

PR-URL: https://github.com/joyent/node/pull/9375
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
v0.12.2-release
Fedor Indutny 10 years ago
parent
commit
a33f23cbbc
  1. 6
      lib/buffer.js

6
lib/buffer.js

@ -86,6 +86,12 @@ function Buffer(subject, encoding) {
poolOffset,
poolOffset + this.length);
poolOffset += this.length;
// Ensure aligned slices
if (poolOffset & 0x7) {
poolOffset |= 0x7;
poolOffset++;
}
} else {
alloc(this, this.length);
}

Loading…
Cancel
Save