[gimp] plug-ins: always stop on error after reading PSD layer block.



commit e1fcaaaa0a6cb567af1ba3f0513bf84e70d901d4
Author: Jacob Boerema <jgboerema gmail com>
Date:   Mon May 17 21:26:18 2021 -0400

    plug-ins: always stop on error after reading PSD layer block.

 plug-ins/file-psd/psd-load.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index a2ac899db5..8dcfdc0ee5 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -186,8 +186,22 @@ load_image (GFile        *file,
   IFDBG(2) g_debug ("Read layer & mask block at offset %" G_GOFFSET_FORMAT,
                     PSD_TELL(input));
   lyr_a = read_layer_block (&img_a, input, &error);
-  if (! img_a.merged_image_only && img_a.num_layers != 0 && lyr_a == NULL)
-    goto load_error;
+  /* No layer or layer info is apparently valid so only check for presence of error. */
+  if (error)
+    {
+      goto load_error;
+    }
+  else if (lyr_a == NULL)
+    {
+      if (img_a.num_layers > 0)
+        {
+          g_warning ("No error message but loading layer failed. This should not happen!");
+          goto load_error;
+        }
+      else
+        /* Only a merged image present, no layers. */
+        img_a.merged_image_only = TRUE;
+    }
   gimp_progress_update (0.4);
 
   /* ----- Read the PSD file Merged Image Data block ----- */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]