[babl] babl: avoid using half initialized LUTs when used from threads
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] babl: avoid using half initialized LUTs when used from threads
- Date: Sun, 23 Jan 2022 22:35:40 +0000 (UTC)
commit da2dc167d0a9a522adfcd3ef609d6ff599b8036b
Author: Øyvind Kolås <pippin gimp org>
Date: Sun Jan 23 23:35:34 2022 +0100
babl: avoid using half initialized LUTs when used from threads
babl/babl-fish-path.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index e372d4f..7d9e825 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -721,8 +721,7 @@ babl_fish_path_process (const Babl *babl,
((Babl*)babl)->fish.pixels += n;
if (!lut && babl->fish.pixels > 256 * 128)
{
- ((Babl*)babl)->fish_path.u8_lut = malloc (256 * 256 * 256 * 4);
- lut = (uint32_t*)babl->fish_path.u8_lut;
+ lut = malloc (256 * 256 * 256 * 4);
if (babl->fish_path.source_bpp == 8)
{
uint64_t *lut_in = malloc (256 * 256 * 256 * 8);
@@ -758,6 +757,18 @@ babl_fish_path_process (const Babl *babl,
babl->fish_path.dest_bpp,
256*256*256);
}
+ // XXX : there is still a micro race, if lost we should only
+ // leak a LUT not produce wrong results.
+ if (babl->fish_path.u8_lut == NULL)
+ {
+ (((Babl*)babl)->fish_path.u8_lut) = (uint8_t*)lut;
+
+ }
+ else
+ {
+ free (lut);
+ lut = (uint32_t*)babl->fish_path.u8_lut;
+ }
}
if (lut)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]