mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
buffer: fix assert fail from JS API
Length arguments passed to SlowBuffer were coerced to Int32, not Uint32, so passing a negative number would throw the following: node: ../src/smalloc.cc:244: void node::smalloc::Alloc(): Assertion `length <= kMaxLength' failed. Aborted (core dumped) That has been fixed by coercing to Uint32 and comparing the value against kMaxLength.
This commit is contained in:
1 parent
16a60ed2a3
commit
873b5f8428
1 file changed
+3
-1
+3
-1
@@ -89,7 +89,9 @@ function Buffer(subject, encoding) {
|
||||
|
||||
|
||||
function SlowBuffer(length) {
|
||||
length = ~~length;
|
||||
length = length >>> 0;
|
||||
if (length > kMaxLength)
|
||||
throw new RangeError('length > kMaxLength');
|
||||
var b = new NativeBuffer(length);
|
||||
alloc(b, length);
|
||||
return b;
|
||||
|
||||
Reference in new issue
Block a user