aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-05 09:02:48 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-05 11:37:04 -0800
commitc1149567884bdafbdf5498abcc4ed7bef50571be (patch)
treec894df70dd69bd68fd82f39a24563fdfce78b81c
parent61bf957b995a28e5aa68a2e592e49d512c96f8ee (diff)
downloadbun-c1149567884bdafbdf5498abcc4ed7bef50571be.tar.gz
bun-c1149567884bdafbdf5498abcc4ed7bef50571be.tar.zst
bun-c1149567884bdafbdf5498abcc4ed7bef50571be.zip
Fix crash when passing unexpected type to .writer()
-rw-r--r--src/bun.js/webcore/response.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig
index b31bd3075..a333ad123 100644
--- a/src/bun.js/webcore/response.zig
+++ b/src/bun.js/webcore/response.zig
@@ -3039,6 +3039,11 @@ pub const Blob = struct {
var arguments_ = callframe.arguments(1);
var arguments = arguments_.ptr[0..arguments_.len];
+ if (!arguments.ptr[0].isEmptyOrUndefinedOrNull() and !arguments.ptr[0].isObject()) {
+ globalThis.throwInvalidArguments("options must be an object or undefined", .{});
+ return JSValue.jsUndefined();
+ }
+
var store = this.store orelse {
globalThis.throwInvalidArguments("Blob is detached", .{});
return JSValue.jsUndefined();
@@ -3075,7 +3080,7 @@ pub const Blob = struct {
},
};
- if (arguments.len > 0) {
+ if (arguments.len > 0 and arguments.ptr[0].isObject()) {
stream_start = JSC.WebCore.StreamStart.fromJSWithTag(globalThis, arguments[0], .FileSink);
stream_start.FileSink.input_path = input_path;
}