Tom94 / tev

High dynamic range (HDR) image viewer for graphics people
BSD 3-Clause "New" or "Revised" License
1.03k stars 87 forks source link

tev crashes with pgm files that contain comments #86

Open vchizhov opened 4 years ago

vchizhov commented 4 years ago

If I have comments # some comment here in a pgm file, tev crashes upon trying to open it. It works fine with pgm files not containing comments however.

Tom94 commented 4 years ago

Hi there! Thanks for letting me know. Can you provide sample files for me to test? Ideally, one PGM without a comment that works and another one with a comment that doesn't work.

vchizhov commented 4 years ago

You can find two images here: https://drive.google.com/open?id=1xIhlVBwbFfgehWgAO-7YHJ_YgsgUeZ1x The _no_comment image is exactly the same as the other, but with the comments removed. Both work fine in IrfanView on Windows and xv on Linux.

Tom94 commented 4 years ago

Thanks for the images!

It appears that stb_image, the underlying library responsible for loading PGM images, does not support comments---see here. Unfortunately, I can't do much about that until I maybe get some time to implement my own PGM decoder---which doesn't actually look extremely involved. Best bet is to create an issue over at the stb_image repo.

That said, tev really should handle this more gracefully... stb_image gives tev a 0x0 image upon trying to load the PGM, which leads to a crash. This is something I'll definitely address.

vchizhov commented 4 years ago

Thank you for looking into it. I submitted an issue with stb, hopefully that gets handled (unfortunately my current workload does not allow me the time to go and fix it myself), since I am also using stb_image in some probjects.