From 0d9cb78f036554de8a9adc9196769e1fc709ea39 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Tue, 30 Nov 2021 22:52:34 +0100 Subject: Force sanitizers for debug builds --- fastiv-io.c | 8 ++++---- meson.build | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fastiv-io.c b/fastiv-io.c index c40b589..b955622 100644 --- a/fastiv-io.c +++ b/fastiv-io.c @@ -299,8 +299,8 @@ load_wuffs_frame(struct load_wuffs_frame_context *ctx, GError **error) uint32_t *out = (uint32_t *) surface_data; for (uint32_t y = 0; y < ctx->height; y++) { for (uint32_t x = 0; x < ctx->width; x++) { - uint16_t b = *in++, g = *in++, r = *in++, x = *in++; - *out++ = (x >> 14) << 30 | + uint32_t b = *in++, g = *in++, r = *in++, X = *in++; + *out++ = (X >> 14) << 30 | (r >> 6) << 20 | (g >> 6) << 10 | (b >> 6); } } @@ -1671,8 +1671,8 @@ read_spng_thumbnail( ihdr.color_type == SPNG_COLOR_TYPE_TRUECOLOR_ALPHA || !spng_get_trns(ctx, &trns)) { for (size_t i = size / sizeof *data; i--; ) { - const uint8_t *unit = (const uint8_t *) &data[i], - a = unit[3], + const uint8_t *unit = (const uint8_t *) &data[i]; + uint32_t a = unit[3], b = unit[2] * a / 255, g = unit[1] * a / 255, r = unit[0] * a / 255; diff --git a/meson.build b/meson.build index 3780515..34508c6 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,13 @@ add_project_arguments( language : 'c', ) +if get_option('buildtype').startswith('debug') + flags = meson.get_compiler('c').get_supported_arguments( + '-fsanitize=address,undefined') + add_project_arguments(flags, language : ['c']) + add_project_link_arguments(flags, language : ['c']) +endif + # TODO(p): Use libraw_r later, when we start parallelizing/preloading. libraw = dependency('libraw', required : get_option('libraw')) librsvg = dependency('librsvg-2.0', required : get_option('librsvg')) -- cgit v1.2.3-70-g09d2