diff options
author | Benjamin Gruenbaum <benjamingr@gmail.com> | 2022-02-11 12:32:10 +0200 |
---|---|---|
committer | Benjamin Gruenbaum <benjamingr@gmail.com> | 2022-02-14 18:29:44 +0200 |
commit | aff8b874e3e52f93971f1d50860e1ae2263f665c (patch) | |
tree | 372837738180c99761708e479d414f71cdc9bc16 /lib/fs.js | |
parent | 98cbbbb9b02c3682fd5278641c5b6b23301afb16 (diff) | |
download | node-new-aff8b874e3e52f93971f1d50860e1ae2263f665c.tar.gz |
fs: fix cb/sync writev empty array behavior
PR-URL: https://github.com/nodejs/node/pull/41932
Refs: https://github.com/nodejs/node/issues/41910
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/fs.js')
-rw-r--r-- | lib/fs.js | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -906,6 +906,11 @@ function writev(fd, buffers, position, callback) { validateBufferArray(buffers); callback = maybeCallback(callback || position); + if (buffers.length === 0) { + process.nextTick(callback, null, 0, buffers); + return; + } + const req = new FSReqCallback(); req.oncomplete = wrapper; @@ -932,6 +937,10 @@ function writevSync(fd, buffers, position) { fd = getValidatedFd(fd); validateBufferArray(buffers); + if (buffers.length === 0) { + return 0; + } + const ctx = {}; if (typeof position !== 'number') |