Don't fill colormap beyond end of screen depth.

diff --git a/graphics/x11drv/dib.c b/graphics/x11drv/dib.c
index 7a692d1..4b2c3e3 100644
--- a/graphics/x11drv/dib.c
+++ b/graphics/x11drv/dib.c
@@ -137,6 +137,10 @@
 
     if (coloruse == DIB_RGB_COLORS)
     {
+	int max = 1 << depth;
+
+	if (end > max) end = max;
+
         if (quads)
         {
             RGBQUAD * rgb = (RGBQUAD *)colorPtr;