Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(python): Fix arithmetic overflow in oiio_bufinfo (Python interop) (…
…#3931) When an incoming 1-dimensional, buffer-like, object was used in Python, the corresponding check inside OIIO would overflow if its length exceeded a signed 32bit value. An error similar to `Pixel data array error: Python array shape is [2304000000] but expecting h=24000, w=24000, ch=4` would be raised. I modified a few similar calculations and tried to follow the predominant pattern already used. Tested using the following snippet which would previously fail: ``` import OpenImageIO as oiio import numpy as np filename = "t:/foo.png" xres = 24000 yres = 24000 channels = 4 # RGB pixels = np.zeros(xres * yres * channels, dtype=np.uint8) spec = oiio.ImageSpec(xres, yres, channels, "uint8") image = oiio.ImageOutput.create(filename) image.open(filename, spec) if not image.write_image(pixels): print("error = ", image.geterror()) image.close() ``` --------- Signed-off-by: Jesse Yurkovich <[email protected]>
- Loading branch information