Skip to content

Commit 07c0667

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 io.js should do this too for compatibility. PR-URL: #1126 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-by: Bert Belder <[email protected]>
1 parent d33a647 commit 07c0667

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
@@ -157,6 +157,12 @@ function palloc(that, length) {
157157
var buf = sliceOnto(allocPool, that, start, end);
158158
poolOffset = end;
159159

160+
// Ensure aligned slices
161+
if (poolOffset & 0x7) {
162+
poolOffset |= 0x7;
163+
poolOffset++;
164+
}
165+
160166
return buf;
161167
}
162168

0 commit comments

Comments
 (0)