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

divide by zero, perhaps multiplication overflow #1076

Closed
setharnold opened this issue Feb 14, 2018 · 0 comments
Closed

divide by zero, perhaps multiplication overflow #1076

setharnold opened this issue Feb 14, 2018 · 0 comments
Labels
removed_components Issues that affect MJ2, JPWL or JP3D wontfix

Comments

@setharnold
Copy link
Contributor

frame_size = (long)(tk->w * tk->h * (1.0 + (double) 2 / (double)(

Hello,

This code mixes doubles and integers in an odd way; I do not know if the tk->w * tk->h multiplication can overflow the integer values or not. The tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy step is probably carried out as integers, and thus a 0 result here is possible.

Floating point is difficult enough already without using integers in the same expressions. I'd feel much more confident about the safety of this code if it were re-written to avoid mixing types and was prepared to handle the potential integer overflows in the multiplications.

   frame_size = (long)(tk->w * tk->h * (1.0 + (double) 2 / (double)(
            tk->CbCr_subsampling_dx *
            tk->CbCr_subsampling_dy)));  /* Calculate frame size */
frame_size *= prec_size;

Thanks

@rouault rouault added wontfix removed_components Issues that affect MJ2, JPWL or JP3D labels May 6, 2021
@rouault rouault closed this as completed May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
removed_components Issues that affect MJ2, JPWL or JP3D wontfix
Projects
None yet
Development

No branches or pull requests

2 participants