UB in ident table
Closed this issue · 1 comments
IdentId
has an inner NonZeroU32
member:
ruruby/ruruby-common/src/id_table.rs
Line 14 in a21f215
But the <null>
ident is defined with symbol ID 0
:
ruruby/ruruby-common/src/id_table.rs
Line 158 in a21f215
IdentId::from
should probably either be replaced with a TryFrom
impl or an unsafe function like IdentId::new_unchchecked
. From
impls cannot be unsafe and ideally shouldn't have safety pre-conditions (which indicates that the fn should be unsafe
).
Hi, Thank you for reading my code and giving me the issue!
Yes, as you may know, IdentId(0) is a kind of dummy data, and not expected to be accessed.
And this code seems to be inappropriate as you pointed out.
Fixed in #29.