[gimp/gimp-2-10] plug-ins: fix #1351 Raw Data Import Creates Blank/White Image...



commit bb76dad3582f319e872d2a5e46ffbfeb693a639f
Author: Jacob Boerema <jgboerema gmail com>
Date:   Mon May 16 14:00:10 2022 -0400

    plug-ins: fix #1351 Raw Data Import Creates Blank/White Image...
    
    when Offset and Dimensions Bigger than File Size.
    
    If we didn't read the exact amount of bytes, the whole image would be
    filled with white.
    
    Let's change this, so we read as much bytes as we can, and fill the rest
    with white.
    
    (cherry picked from commit 3644b9010aff6ed25270d323c46588d500911711)

 plug-ins/common/file-raw-data.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/common/file-raw-data.c b/plug-ins/common/file-raw-data.c
index 3d2daaddca..33070ea0b5 100644
--- a/plug-ins/common/file-raw-data.c
+++ b/plug-ins/common/file-raw-data.c
@@ -743,12 +743,15 @@ raw_read_row (FILE   *fp,
               gint32  offset,
               gint32  size)
 {
+  size_t bread;
+
   fseek (fp, offset, SEEK_SET);
 
-  if (! fread (buf, size, 1, fp))
+  memset (buf, 0xFF, size);
+  bread = fread (buf, 1, size, fp);
+  if (bread < size)
     {
-      g_printerr ("fread failed\n");
-      memset (buf, 0xFF, size);
+      g_printerr ("fread failed: read %u instead of %u bytes\n", (guint) bread, (guint) size);
     }
 }
 


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