[gimp/gimp-2-10] plug-ins: Take zero length layer names into account in psp reader.



commit 3765f80652c6ac1d8cbdf9ee21e86efc2bf22949
Author: Jacob Boerema <jgboerema gmail com>
Date:   Sun Aug 30 16:34:03 2020 -0400

    plug-ins: Take zero length layer names into account in psp reader.
    
    (cherry picked from commit d7089c9)

 plug-ins/common/file-psp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/common/file-psp.c b/plug-ins/common/file-psp.c
index b945168fc8..023655e036 100644
--- a/plug-ins/common/file-psp.c
+++ b/plug-ins/common/file-psp.c
@@ -1360,9 +1360,11 @@ read_layer_block (FILE      *f,
         {
           if (fread (&chunk_len, 4, 1, f) < 1
               || fread (&namelen, 2, 1, f) < 1
-              || ((namelen = GUINT16_FROM_LE (namelen)) && FALSE)
+              /* A zero length layer name is apparently valid. To not get a warning for
+                 namelen < 0 always being false we use this more complicated comparison. */
+              || ((namelen = GUINT16_FROM_LE (namelen)) && (FALSE || namelen == 0))
               || (name = g_malloc (namelen + 1)) == NULL
-              || fread (name, namelen, 1, f) < 1
+              || (namelen > 0 && fread (name, namelen, 1, f) < 1)
               || fread (&type, 1, 1, f) < 1
               || fread (&image_rect, 16, 1, f) < 1
               || fread (&saved_image_rect, 16, 1, f) < 1


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