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 67b80d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 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 &&
(!encoding || encoding === 'ascii' || encoding === 'utf8')
(!encoding || encoding === 'ascii' || encoding === 'utf8') &&
typeof string === 'string'
) {
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 67b80d8

Please sign in to comment.