mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
catch pointer overflows in createLookupKey
Its better to have this; if this is incorrect, its better to get notified.
This commit is contained in:
@@ -485,8 +485,10 @@ fn findListener(list: *const std.DoublyLinkedList, typ: []const u8, callback: Ca
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a lookup key to use with `inline_lookup`.
|
/// Creates a lookup key to use with `inline_lookup`.
|
||||||
inline fn createLookupKey(event_target: *EventTarget, event_type: Listener.Type) usize {
|
fn createLookupKey(event_target: *EventTarget, event_type: Listener.Type) usize {
|
||||||
return @intFromPtr(event_target) >> 3 | (@as(u64, @intFromEnum(event_type)) << 57);
|
const ptr = @intFromPtr(event_target) >> 3;
|
||||||
|
lp.assert(ptr < (1 << 57), "createLookupKey: pointer overflow", .{ .ptr = ptr });
|
||||||
|
return ptr | (@as(u64, @intFromEnum(event_type)) << 57);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns listener type from `inline_lookup` key.
|
/// Returns listener type from `inline_lookup` key.
|
||||||
|
|||||||
Reference in New Issue
Block a user