From ae69a754244c4e475c8d2591772ca8e005071d83 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 18 Feb 2019 11:55:41 +0100 Subject: Update to 5.42 --- utils/colors.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'utils/colors.c') diff --git a/utils/colors.c b/utils/colors.c index e6abd48..5445cd6 100644 --- a/utils/colors.c +++ b/utils/colors.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1997-2013 Jamie Zawinski +/* xscreensaver, Copyright (c) 1997-2018 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -383,9 +383,22 @@ make_color_path (Screen *screen, Visual *visual, Colormap cmap, /* Floating-point round-off can make us decide to use fewer colors. */ if (k < *ncolorsP) { + /* We used to just return the smaller set of colors, but that meant + that after re-generating the color map repeatedly, the number of + colors in use would tend toward 0, which not only looked bad but + also often caused crashes. So instead, just duplicate the last + color to pad things out. */ +# if 0 *ncolorsP = k; if (k <= 0) return; +# else + for (i = k+1; i < *ncolorsP; i++) + /* #### Should duplicate the allocation of the color cell here + to avoid a double-color-free on PseudoColor, but it's 2018 + and I don't care, */ + colors[i] = colors[k]; +# endif } if (!allocate_p) -- cgit v1.2.3-55-g7522