From: Ell Date: Thu, 14 Jun 2018 06:16:08 +0000 (-0400) Subject: babl-palette: warn when trying to create a palette with > 256 colors X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~16^2~47 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=dc4c7706ac5a4ad085a1cf63c19922abc997c5fc;p=babl.git babl-palette: warn when trying to create a palette with > 256 colors ... and only use the first 256 colors. --- diff --git a/babl/babl-palette.c b/babl/babl-palette.c index 278c854..c70d4ed 100644 --- a/babl/babl-palette.c +++ b/babl/babl-palette.c @@ -872,6 +872,16 @@ babl_palette_set_palette (const Babl *babl, { BablPalette **palptr = babl_get_user_data (babl); babl_palette_reset (babl); + + if (count > 256) + { + babl_log ("attempt to create a palette with %d colors. " + "truncating to 256 colors.", + count); + + count = 256; + } + if (count > 0) { *palptr = make_pal (format, data, count);