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

Potential integer overflow #317

Closed
sizov-kirill opened this issue Jun 29, 2021 · 0 comments · Fixed by #319
Closed

Potential integer overflow #317

sizov-kirill opened this issue Jun 29, 2021 · 0 comments · Fixed by #319
Assignees
Labels
BUG Something isn't working

Comments

@sizov-kirill
Copy link

In the code below we see that img can be of type uint8, then img is multiplied by 28 and 216, but uint8 cannot store such large numbers.

def bgr2index(img):
if img.dtype.kind not in {'b', 'i', 'u'}:
img = img.astype(np.uint8)
return (img[..., 0] << 16) + (img[..., 1] << 8) + img[..., 2]

@sizov-kirill sizov-kirill self-assigned this Jun 29, 2021
@zhiltsov-max zhiltsov-max added the BUG Something isn't working label Jun 29, 2021
@sizov-kirill sizov-kirill mentioned this issue Jun 29, 2021
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants