Please sign in to comment.
buffer: throw on negative .allocUnsafe() argument
Add a check for `size < 0` to `assertSize()`, as passing a negative value almost certainly indicates a programming error. This also lines up the behaviour of `.allocUnsafe()` with the ones of `.alloc()` and `.allocUnsafeSlow()` (which previously threw errors from the Uint8Array constructor). Notably, this also affects `Buffer()` calls with negative arguments. PR-URL: #7079 Reviewed-By: Trevor Norris <firstname.lastname@example.org> Reviewed-By: Сковорода Никита Андреевич <email@example.com> Reviewed-By: Colin Ihrig <firstname.lastname@example.org> Reviewed-By: James M Snell <email@example.com> Reviewed-By: Yorkie Liu <firstname.lastname@example.org>
- Loading branch information...
Showing with 38 additions and 8 deletions.