aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-05-26 21:18:31 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-05-26 21:18:31 -0700
commit7094997eec556368b895a3668ebf95330306eb97 (patch)
tree5cd953e67ca35a3b6f9443aebd5400ff0190a039 /src
parent79907fe84ceb186ba96b4ac7dff4b7ada47c6850 (diff)
downloadbun-7094997eec556368b895a3668ebf95330306eb97.tar.gz
bun-7094997eec556368b895a3668ebf95330306eb97.tar.zst
bun-7094997eec556368b895a3668ebf95330306eb97.zip
Fix crash in `Server.prototype.fetch()` helper functionbun-v0.6.4
cc @cirospaciari, if you use `mimalloc-debug` it catches things like this
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/api/server.zig12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index 9af44deba..094f5e385 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -4659,8 +4659,8 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
// TODO: set Host header
// TODO: set User-Agent header
if (first_arg.isString()) {
- var url_zig_str = ZigString.init("");
- JSValue.fromRef(arguments[0]).toZigString(&url_zig_str, globalThis);
+ const url_zig_str = JSValue.c(arguments[0]).toSlice(globalThis, bun.default_allocator);
+ defer url_zig_str.deinit();
var temp_url_str = url_zig_str.slice();
if (temp_url_str.len == 0) {
@@ -4706,12 +4706,18 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
existing_request = Request{
.url = url.href,
+ .url_was_allocated = true,
.headers = headers,
.body = JSC.WebCore.InitRequestBodyValue(body) catch unreachable,
.method = method,
};
} else if (first_arg.as(Request)) |request_| {
- existing_request = request_.*;
+ request_.cloneInto(
+ &existing_request,
+ bun.default_allocator,
+ globalThis,
+ false,
+ );
} else {
const fetch_error = WebCore.Fetch.fetch_type_error_strings.get(js.JSValueGetType(ctx, arguments[0]));
return JSPromise.rejectedPromiseValue(globalThis, ZigString.init(fetch_error).toErrorInstance(globalThis)).asRef();