[gimp/gimp-2-10] plug-ins: fix crash of qbist when loading files.



commit 90f8cb54ebd50d5dfd3a653e1713421d04bb79c5
Author: Jehan <jehan girinstud io>
Date:   Tue Mar 23 19:29:02 2021 +0100

    plug-ins: fix crash of qbist when loading files.
    
    Contents of these arrays are assumed to be limited to a specific range.
    While it did work sometimes (because a further processing would randomly
    regenerate some of the indexes and correctly limit the range), it often
    crashed.
    
    This commit fixes the crash, but I am not sure this plug-in is working
    exactly as expected regarding data load/save. It feels like you would
    expect to always get the same patterns with a same source data. Yet
    there is further randomization going on.
    
    Oppositely when saving data, and re-loading it later, I would expect
    once again to get back the exact same patterns I had when saving the
    data. So it would be a way to save the result of randomization (as
    chances to get back a pattern one liked are slim by definition when it's
    created randomly).
    
    Right now, it doesn't behave at all like this. Files are only used as
    some kind of random seed, not as a way to save/load patterns. I feel
    this was not the purpose of the file handling here.
    
    (cherry picked from commit 7fb696206e72b8ea61f74e56f36adbfc6b9b0f17)

 plug-ins/common/qbist.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/common/qbist.c b/plug-ins/common/qbist.c
index f8f94d4004..5b4a6ed67f 100644
--- a/plug-ins/common/qbist.c
+++ b/plug-ins/common/qbist.c
@@ -646,16 +646,16 @@ load_data (gchar *name)
 
   for (i = 0; i < MAX_TRANSFORMS; i++)
     info[0].transformSequence[i] =
-      get_be16 (buf + i * 2 + MAX_TRANSFORMS * 2 * 0);
+      get_be16 (buf + i * 2 + MAX_TRANSFORMS * 2 * 0) % NUM_TRANSFORMS;
 
   for (i = 0; i < MAX_TRANSFORMS; i++)
-    info[0].source[i] = get_be16 (buf + i * 2 + MAX_TRANSFORMS * 2 * 1);
+    info[0].source[i] = get_be16 (buf + i * 2 + MAX_TRANSFORMS * 2 * 1) % NUM_REGISTERS;
 
   for (i = 0; i < MAX_TRANSFORMS; i++)
-    info[0].control[i] = get_be16 (buf + i * 2 + MAX_TRANSFORMS * 2 * 2);
+    info[0].control[i] = get_be16 (buf + i * 2 + MAX_TRANSFORMS * 2 * 2) % NUM_REGISTERS;
 
   for (i = 0; i < MAX_TRANSFORMS; i++)
-    info[0].dest[i] = get_be16 (buf + i * 2 + MAX_TRANSFORMS * 2 * 3);
+    info[0].dest[i] = get_be16 (buf + i * 2 + MAX_TRANSFORMS * 2 * 3) % NUM_REGISTERS;
 
   return TRUE;
 }


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