Guest User

Untitled

a guest
Jul 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. if (i_width_aligned > UINT64_MAX/i_height_aligned)
  2. error();
  3.  
  4. uint64_t i_pixels_divided = ((uint64_t)i_width_aligned * i_height_aligned) / 8;
  5.  
  6. size_t bpp = p_pic->format.i_bits_per_pixel;
  7.  
  8. if (i_pixels_divided > SIZE_MAX/bpp)
  9. error();
  10.  
  11. uint64_t i_bytes = i_pixels_divided * bpp;
  12.  
  13. // use i_bytes to allocate space; no need for any more checks.
Add Comment
Please, Sign In to add comment