From: Øyvind Kolås Date: Thu, 14 May 2020 15:53:50 +0000 (+0200) Subject: babl: slightly pad source buffers for creating conversions X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~9^2~17 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=411dae60ae1c564090fa7c6a3943550ec1f1d1be;p=babl.git babl: slightly pad source buffers for creating conversions 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. --- diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c index 7cca1f2..6c5d4f1 100644 --- a/babl/babl-conversion.c +++ b/babl/babl-conversion.c @@ -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); diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c index f641a21..a62f32a 100644 --- a/babl/babl-fish-reference.c +++ b/babl/babl-fish-reference.c @@ -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;