QueryColorMap() function in multiVis.c may retrieve incorrect colours
In QueryColorMap XColor array is allocated by malloc() function which does not initialise allocated memory. So if the memory contains some “garbage”, which is not cleared out during array elements initialisation, the array with incorrect data is passed to XQueryColors() often causing problems such as incorrect colour retrieval.
Possible fix: Replace malloc() with calloc(), which initialises allocated memory with 0, for XColor array allocation in QueryColorMap() function
Patch:
@@ -218,7 +218,11 @@ XColor *colors ; ncolors = (unsigned) src_vis->map_entries ; - *src_colors = colors = (XColor *)malloc(ncolors * sizeof(XColor) ) ; + *src_colors = colors = (XColor *)calloc(ncolors, sizeof(XColor)); if(src_vis->class != TrueColor && src_vis->class != DirectColor) {
Edited by Dmitry Markov