Skip to content

Commit 67b80d8

Browse files
committed
fixup
1 parent ebbe73f commit 67b80d8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/buffer.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1108,15 +1108,16 @@ Buffer.prototype.write = function write(string, offset, length, encoding) {
11081108
}
11091109
}
11101110

1111-
const len = string.length;
1111+
const len = string?.length;
11121112
if (
11131113
len <= 16 &&
11141114
len <= length &&
1115-
(!encoding || encoding === 'ascii' || encoding === 'utf8')
1115+
(!encoding || encoding === 'ascii' || encoding === 'utf8') &&
1116+
typeof string === 'string'
11161117
) {
11171118
let n = 0;
11181119
while (true) {
1119-
const code = string.charCodeAt(n);
1120+
const code = StringPrototypeCharCodeAt(string, n);
11201121
if (code >= 128) {
11211122
break;
11221123
}

0 commit comments

Comments
 (0)