Skip to content

Commit a33f23c

Browse files
committed
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: nodejs/node-v0.x-archive#9375 Reviewed-By: Trevor Norris <[email protected]>
1 parent cc6ee3f commit a33f23c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/buffer.js

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ function Buffer(subject, encoding) {
8686
poolOffset,
8787
poolOffset + this.length);
8888
poolOffset += this.length;
89+
90+
// Ensure aligned slices
91+
if (poolOffset & 0x7) {
92+
poolOffset |= 0x7;
93+
poolOffset++;
94+
}
8995
} else {
9096
alloc(this, this.length);
9197
}

0 commit comments

Comments
 (0)