fs: fix fs.read when passing null value

PR-URL: https://github.com/nodejs/node/pull/32479
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
This commit is contained in:
himself65
2020-03-25 16:36:35 +08:00
committed by Anna Henningsen
parent fb254d2a83
commit defbc2ed82
2 changed files with 14 additions and 4 deletions

View File

@@ -484,10 +484,12 @@ function read(fd, buffer, offset, length, position, callback) {
callback = offset;
}
buffer = options.buffer || Buffer.alloc(16384);
offset = options.offset || 0;
length = options.length || buffer.length;
position = options.position;
({
buffer = Buffer.alloc(16384),
offset = 0,
length = buffer.length,
position
} = options);
}
validateBuffer(buffer);