fix(Response): initialize #url field to prevent crash on Windows

The Response constructor and Response.error() were not initializing the
#url field, leaving it with uninitialized memory. When calculateEstimatedByteSize()
was called (which happens in toJS()), it would call byteSlice() on the
uninitialized String, causing a "switch on corrupt value" panic when the
String.tag field contained garbage.

This fix explicitly initializes #url to bun.String.empty in both:
- Response.constructor()
- Response.constructError()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2026-01-31 21:55:54 +00:00
parent a14a89ca95
commit ab29769b95

View File

@@ -668,6 +668,7 @@ pub fn constructError(
.#body = Body{
.value = .{ .Empty = {} },
},
.#url = bun.String.empty,
},
);
@@ -751,6 +752,7 @@ pub fn constructor(globalThis: *jsc.JSGlobalObject, callframe: *jsc.CallFrame, j
var response = bun.new(Response, Response{
.#body = body,
.#init = _init,
.#url = bun.String.empty,
.#js_ref = .initWeak(js_this),
});