aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-07-30 16:18:13 +0800
committerGravatar GitHub <noreply@github.com> 2023-07-30 01:18:13 -0700
commit413fd281208f24a532c47249dec1bfc3aef2bf37 (patch)
tree824f840e3b1cf637b8a632fac7b1ff04fca1afb9 /src
parent40a9ba63409694443058f558df2e480a8f16ff54 (diff)
downloadbun-413fd281208f24a532c47249dec1bfc3aef2bf37.tar.gz
bun-413fd281208f24a532c47249dec1bfc3aef2bf37.tar.zst
bun-413fd281208f24a532c47249dec1bfc3aef2bf37.zip
Fix coredump when reading an empty file(`node:stream:createReadStream`) (#3882)
* Fix coredump when reading an empty file. Close: #3607 * It seems that the fd is closed when `auto_close` is true.
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/webcore/streams.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig
index 5dc4ea830..f2c5914ef 100644
--- a/src/bun.js/webcore/streams.zig
+++ b/src/bun.js/webcore/streams.zig
@@ -4433,6 +4433,10 @@ pub const FileReader = struct {
var readable_file = File{ .loop = this.globalThis().bunVM().eventLoop() };
const result = readable_file.start(&blob.data.file);
+ if (result == .empty) {
+ this.lazy_readable = .{ .empty = {} };
+ return result;
+ }
if (result != .ready) {
return result;
}