From c7111d5e874a5b5b9cdc57d74b748c68123d77a9 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 11 Mar 2015 07:17:53 -0700 Subject: [PATCH] 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 io.js should do this too for compatibility. --- lib/buffer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/buffer.js b/lib/buffer.js index dde229a2ea99ab..f125806622d49d 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -157,6 +157,12 @@ function palloc(that, length) { var buf = sliceOnto(allocPool, that, start, end); poolOffset = end; + // Ensure aligned slices + if (poolOffset & 0x7) { + poolOffset |= 0x7; + poolOffset++; + } + return buf; }