Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c6dc2a1

Browse filesBrowse files
brycebarilMyles Borins
authored andcommitted
buffer: Prevent Buffer constructor deopt
The Buffer constructor will generally get inlined, but any call to the Buffer constructor for a string without encoding will cause an eager deoptimization of any function that inlined the Buffer constructor. This is due to a an out-of-bounds read on `arguments[1]`. This change prevents that deopt. PR-URL: #4158 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
1 parent c5f71ac commit c6dc2a1
Copy full SHA for c6dc2a1

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Collapse file

‎lib/buffer.js‎

Copy file name to clipboardExpand all lines: lib/buffer.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function alignPool() {
4040
}
4141

4242

43-
function Buffer(arg) {
43+
function Buffer(arg, encoding) {
4444
// Common case.
4545
if (typeof arg === 'number') {
4646
// If less than zero, or NaN.
@@ -51,7 +51,7 @@ function Buffer(arg) {
5151

5252
// Slightly less common case.
5353
if (typeof arg === 'string') {
54-
return fromString(arg, arguments[1]);
54+
return fromString(arg, encoding);
5555
}
5656

5757
// Unusual.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.