Skip to content

Commit d8eb307

Browse files
committed
fixup
1 parent ebbe73f commit d8eb307

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/buffer.js

+3-2
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+
typeof string === 'string' &&
11151116
(!encoding || encoding === 'ascii' || encoding === 'utf8')
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)