From cb3abe58c28f2db1262d51437d15f1c8725d97d3 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 9 Jan 2024 16:52:28 +0100 Subject: [PATCH] dom: attr: fix crash w/o parent --- src/netsurf.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/netsurf.zig b/src/netsurf.zig index 88565df7..d105fbc9 100644 --- a/src/netsurf.zig +++ b/src/netsurf.zig @@ -863,6 +863,11 @@ pub fn attributeGetValue(a: *Attribute) !?[]const u8 { } pub fn attributeSetValue(a: *Attribute, v: []const u8) !void { + // if the attribute has no owner/parent, the function crashes. + if (try attributeGetOwnerElement(a) == null) { + return DOMError.NotSupported; + } + const err = attributeVtable(a).dom_attr_set_value.?(a, try strFromData(v)); try DOMErr(err); }