From a1813868fcba6e0e990fa294e3d8d7682d66aefb Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 22 Sep 2022 10:19:30 +0900 Subject: [PATCH] [qwaq] Copy only those bytes in the colormap tex The fullbright count byte in a colormap is not in the generated colormap texture data. Attempting to read it results in an angry valgrind. --- ruamoko/qwaq/builtins/graphics.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ruamoko/qwaq/builtins/graphics.c b/ruamoko/qwaq/builtins/graphics.c index e31aa1d27..1f408344c 100644 --- a/ruamoko/qwaq/builtins/graphics.c +++ b/ruamoko/qwaq/builtins/graphics.c @@ -303,7 +303,10 @@ generate_colormap (void) memcpy (colors[i][224], colors[31][224], 32 * 3); } tex_t *cmap = ConvertImage (&tex, default_palette[0]); - memcpy (default_colormap, cmap->data, sizeof (default_colormap)); + // the colormap has an extra byte indicating the number of fullbright + // entries, but that byte is not in the image, so don't try to copy it, + // thus the - 1 + memcpy (default_colormap, cmap->data, sizeof (default_colormap) - 1); free (cmap); }