fix(avatar): prevent u16 overflow panic when seed byte is large
hue_color and accent_color computed (seed as u16) * 360, which overflows u16 when seed >= 182 — debug builds panicked, release wrapped silently. Widen to u32 before the multiplication. This also unblocks several identity_manager tests that constructed avatars through master_node_svg and were aborting on the panic.
This commit is contained in:
parent
f6efe2f356
commit
9d42645aa3
@ -18,12 +18,12 @@ use base64::Engine;
|
||||
/// Convert a byte to an HSL triple biased toward readable foregrounds on
|
||||
/// dark backgrounds (saturation 60–85%, lightness 52–70%).
|
||||
fn hue_color(seed: u8) -> String {
|
||||
let hue = (seed as u16) * 360 / 256;
|
||||
let hue = (seed as u32) * 360 / 256;
|
||||
format!("hsl({}, 72%, 60%)", hue)
|
||||
}
|
||||
|
||||
fn accent_color(seed: u8) -> String {
|
||||
let hue = (seed as u16) * 360 / 256;
|
||||
let hue = (seed as u32) * 360 / 256;
|
||||
format!("hsl({}, 80%, 68%)", hue)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user