Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bun.js/api/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn renderMetadata(this: *RequestContext) void {
var response: *JSC.WebCore.Response = this.response_ptr.?;
var status = response.statusCode();
var needs_content_range = this.needs_content_range;
var needs_content_range = this.needs_content_range and this.sendfile.remain < this.blob.size();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendfile is initialized to undefined, so we need to be extremely careful when it is accessed

I think this is okay because needs_content_range is initialized to false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next line does:

const size = if (needs_content_range)
    this.sendfile.remain
else
    this.blob.size();

Hence I won't be introducing any new NPE here 😏


const size = if (needs_content_range)
this.sendfile.remain
Expand Down
Loading