GNOME Bugzilla – Bug 395385
psd_save fails to save multi-layer images without any visible layers
Last modified: 2008-01-15 13:23:40 UTC
Please describe the problem: Sometimes, i mistakenly save a psd image without visible layers. (For example, when I discard a rough-image layer and save the image before turning some other layers visible). Whenever i do such a manupulation, psd_save.exe crashes. I use wingimp 2.2.13. This happens both on win2000/XP. Steps to reproduce: 1. make multiple-layers 2. make all laters invisible 3. save .psd file Actual results: A message box appears that says psd_save.exe crashes. Expected results: A psd file without visible layer should be saved. Does this happen every time? yes Other information:
psd_save does add a flattened layer to the psd file for multi-layer images, probably to provide a reference rendering. This fails if no layers are visible (gimp-image-flatten does fail). The image can't be saved on Linux, either. Changing platform and summary.
Created attachment 81875 [details] [review] don't crash be returning early Preventing the crash by returning early from write_pixel_data seems to be a trivial solution. This patch was tested with 2.2; I didn't try if any application besides GIMP does load the PSD, though. For trunk, drawable id validation could be used.
The PSD plug-in should probably check the return value of the flatten operation and create an empty drawable as a fallback (if the returned drawable ID is -1).
I am not an expert but from looking at the code I get the impression that the reference layer is not absolutely needed in a PSD file. So we can probably do a quick fix like the one that Michael suggested.
Created attachment 81942 [details] [review] check the return value of gimp_image_flatten
Perhaps the only way to get this tested is to actually commit it. I've done that now in both branches: 2007-02-19 Sven Neumann <sven@gimp.org> * plug-ins/common/psd_save.c: check the return value of gimp_image_flatten(). Fixes the crash reported in bug #395385.