From 90db749ee538d110b884d0b3344fafd6155e3436 Mon Sep 17 00:00:00 2001 From: Ben Heidemann Date: Sun, 18 Apr 2021 16:18:45 +0100 Subject: [PATCH] fix: handle case data = 0 in writeFile --- src/filesystem/implementation.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/filesystem/implementation.js b/src/filesystem/implementation.js index 33ed78c..5e839da 100644 --- a/src/filesystem/implementation.js +++ b/src/filesystem/implementation.js @@ -1869,7 +1869,6 @@ function writeFile(context, path, data, options, callback) { return callback(new Errors.EINVAL('flags is not valid', path)); } - data = data || ''; if(!Buffer.isBuffer(data)) { if(typeof data === 'number') { data = '' + data; @@ -1878,7 +1877,7 @@ function writeFile(context, path, data, options, callback) { data = Buffer.from(data.toString()); } else { - data = Buffer.from(data, options.encoding || 'utf8'); + data = Buffer.from(data || '', options.encoding || 'utf8'); } }