mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +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,
|
.data_callback = httpDataCallback,
|
||||||
.done_callback = httpDoneCallback,
|
.done_callback = httpDoneCallback,
|
||||||
.error_callback = httpErrorCallback,
|
.error_callback = httpErrorCallback,
|
||||||
|
.shutdown_callback = httpShutdownCallback,
|
||||||
});
|
});
|
||||||
|
|
||||||
page.js.strongRef(self);
|
page.js.strongRef(self);
|
||||||
@@ -463,6 +464,11 @@ fn httpErrorCallback(ctx: *anyopaque, err: anyerror) void {
|
|||||||
self._page.js.weakRef(self);
|
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 {
|
pub fn abort(self: *XMLHttpRequest) void {
|
||||||
self.handleError(error.Abort);
|
self.handleError(error.Abort);
|
||||||
if (self._transfer) |transfer| {
|
if (self._transfer) |transfer| {
|
||||||
|
|||||||
@@ -39,9 +39,10 @@ pub const FetchOpts = struct {
|
|||||||
writer: ?*std.Io.Writer = null,
|
writer: ?*std.Io.Writer = null,
|
||||||
};
|
};
|
||||||
pub fn fetch(app: *App, url: [:0]const u8, opts: FetchOpts) !void {
|
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);
|
const notification = try Notification.init(app.allocator);
|
||||||
defer notification.deinit();
|
defer notification.deinit();
|
||||||
|
|
||||||
|
var browser = try Browser.init(app, .{});
|
||||||
defer browser.deinit();
|
defer browser.deinit();
|
||||||
|
|
||||||
var session = try browser.newSession(notification);
|
var session = try browser.newSession(notification);
|
||||||
|
|||||||
Reference in New Issue
Block a user