browser: clear session slot when Session.init fails

newSession set self.session to undefined, but left it non-null if
Session.init failed. closeSession() then ran deinit() on garbage:

- double-released the arena
- read undefined fields on the never-assigned path

Add an errdefer to null the slot on failure.
This commit is contained in:
Adrià Arrufat
2026-06-08 10:05:25 +02:00
parent 29b407bc30
commit bf7992f904

View File

@@ -109,6 +109,7 @@ pub fn deinit(self: *Browser) void {
pub fn newSession(self: *Browser, notification: *Notification) !*Session {
self.closeSession();
self.session = @as(Session, undefined);
errdefer self.session = null;
const session = &self.session.?;
try Session.init(session, self, notification);
return session;