mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-21 20:24:42 +00:00
Merge pull request #1513 from lightpanda-io/fix_crash_on_double_http_abort
Fix double-free of XHR on double client abort
This commit is contained in:
@@ -233,6 +233,7 @@ pub fn send(self: *XMLHttpRequest, body_: ?[]const u8) !void {
|
||||
.data_callback = httpDataCallback,
|
||||
.done_callback = httpDoneCallback,
|
||||
.error_callback = httpErrorCallback,
|
||||
.shutdown_callback = httpShutdownCallback,
|
||||
});
|
||||
|
||||
page.js.strongRef(self);
|
||||
@@ -463,6 +464,11 @@ fn httpErrorCallback(ctx: *anyopaque, err: anyerror) void {
|
||||
self._page.js.weakRef(self);
|
||||
}
|
||||
|
||||
fn httpShutdownCallback(ctx: *anyopaque) void {
|
||||
const self: *XMLHttpRequest = @ptrCast(@alignCast(ctx));
|
||||
self._transfer = null;
|
||||
}
|
||||
|
||||
pub fn abort(self: *XMLHttpRequest) void {
|
||||
self.handleError(error.Abort);
|
||||
if (self._transfer) |transfer| {
|
||||
|
||||
@@ -39,9 +39,10 @@ pub const FetchOpts = struct {
|
||||
writer: ?*std.Io.Writer = null,
|
||||
};
|
||||
pub fn fetch(app: *App, url: [:0]const u8, opts: FetchOpts) !void {
|
||||
var browser = try Browser.init(app, .{});
|
||||
const notification = try Notification.init(app.allocator);
|
||||
defer notification.deinit();
|
||||
|
||||
var browser = try Browser.init(app, .{});
|
||||
defer browser.deinit();
|
||||
|
||||
var session = try browser.newSession(notification);
|
||||
|
||||
Reference in New Issue
Block a user