mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
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:
@@ -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),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user