jamesbowman / openexrpython

OpenEXR bindings for Python
Other
94 stars 35 forks source link

Segmentation fault if line order is set to DECREASING_Y #13

Closed tiagoshibata closed 6 years ago

tiagoshibata commented 6 years ago

Writing to an output EXR file segfaults if the file is set to DECREASING_Y line order (e.g. the file ScanLines/Blobbies.exr in the official openexr-images repository).

Repro: This program copies the header from the ScanLines/Blobbies.exr image to an output image and segfaults in the last line:

import OpenEXR

filename = './tests/openexr-images/ScanLines/Blobbies.exr'
assert OpenEXR.isOpenExrFile(filename)
input_file = OpenEXR.InputFile(filename)
assert input_file.isComplete()
output_header = input_file.header()
print(output_header)
output_file = OpenEXR.OutputFile('output.exr', output_header)
channel_data = {
    'R': input_file.channel('R')
}
output_file.writePixels(channel_data)

There's no way to use decreasing Y line order currently. The writePixels call doesn't crash if increasing Y is explicitly set.

Let me know if someone starts looking into this issue; if not, I will debug it and provide a PR (might take a few weeks though, I'm busy now).

tiagoshibata commented 6 years ago

I started taking a look at this yesterday and have a fix ready. I'll do some more testing and see if I find other crashes before opening a PR.

jamesbowman commented 6 years ago

Sounds good, thanks.