babl: slightly pad source buffers for creating conversions
authorØyvind Kolås <pippin@gimp.org>
Thu, 14 May 2020 15:53:50 +0000 (17:53 +0200)
committerØyvind Kolås <pippin@gimp.org>
Thu, 14 May 2020 16:46:25 +0000 (18:46 +0200)
This is done because many babls conversions get optimized by C compilers
to read 16bytes of data at a time. Causing valgrind to report
"Invalid read of size 16" as a false positive. By padding the data at
least when creating conversions we mask the false positives.

babl/babl-conversion.c
babl/babl-fish-reference.c

index 7cca1f248b7ed4a0f9c243b75c53ac66d0d828a4..6c5d4f16bf08235d79ea9c74489852f775c36e45 100644 (file)
@@ -487,7 +487,9 @@ babl_conversion_error (BablConversion *conversion)
       conversion->error = 0.0000042;
     }
 
-  source                      = babl_calloc (test_pixels, fmt_source->format.bytes_per_pixel);
+  source                      = babl_calloc (test_pixels+1, fmt_source->format.bytes_per_pixel);
+                                                 /* +1 is masking valgrind Invalid read of 16
+                                                  *    false positives */
   destination                 = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
   ref_destination             = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
   destination_rgba_double     = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
index f641a21506c6fd2e7922077619fc560d3d09db1c..a62f32ae1ecdc2383a4f2eff3c1893c6cf775a79 100644 (file)
@@ -1259,7 +1259,8 @@ babl_fish_reference_process_float (const Babl *babl,
     }
     else
     {
-      source_float_buf_alloc = babl_malloc (sizeof (float) * n *
+      /* the +1 is to mask a valgrind 'invalid read of size 16' false positive  */
+      source_float_buf_alloc = babl_malloc (sizeof (float) * (n+1) *
                                   (BABL (babl->fish.source)->format.model->components));
 
       source_float_buf = source_float_buf_alloc;