Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Aug 10, 2024
1 parent ebbe73f commit d8eb307
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,15 +1108,16 @@ Buffer.prototype.write = function write(string, offset, length, encoding) {
}
}

const len = string.length;
const len = string?.length;
if (
len <= 16 &&
len <= length &&
typeof string === 'string' &&
(!encoding || encoding === 'ascii' || encoding === 'utf8')
) {
let n = 0;
while (true) {
const code = string.charCodeAt(n);
const code = StringPrototypeCharCodeAt(string, n);
if (code >= 128) {
break;
}
Expand Down

0 comments on commit d8eb307

Please sign in to comment.