Skip to content

Commit c7111d5

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.
1 parent 8453fbc commit c7111d5

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)