Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Casting a negative number to u32 #33

Closed
dobryak opened this issue Aug 6, 2022 · 1 comment
Closed

Casting a negative number to u32 #33

dobryak opened this issue Aug 6, 2022 · 1 comment
Labels

Comments

@dobryak
Copy link

dobryak commented Aug 6, 2022

Hello.
The result of this subtraction can be negative, that in turn leads to large values in sub.x and sub.y since they are casted to u32.
Also, this will cause u32 overflow in the .copy_from method.

shotgun/src/main.rs

Lines 207 to 208 in 1e5f5d7

x: screen.x - sel.x,
y: screen.y - sel.y,

@9ary
Copy link
Member

9ary commented Aug 6, 2022

Good catch. I see what's going on now. Recent changes turned this:

screens.filter_map(|s| s.intersection(sel)).collect();

into

shotgun/src/main.rs

Lines 193 to 197 in 1e5f5d7

let screens: Vec<util::Rect> = screen_rects
.iter()
.filter(|s| s.intersection(sel).is_some())
.cloned()
.collect();

This is a bug.

@9ary 9ary closed this as completed in 509d12b Sep 2, 2022
@9ary 9ary added the bug label May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants