6cbc11f12e044ca1c29cef76f2c1e1fcabcb54c0
braney
  Thu Oct 31 17:02:13 2024 -0700
don't overwrite the end of the array

diff --git src/hg/hgTracks/wigTrack.c src/hg/hgTracks/wigTrack.c
index 0c41c8c..d423c62 100644
--- src/hg/hgTracks/wigTrack.c
+++ src/hg/hgTracks/wigTrack.c
@@ -74,30 +74,32 @@
     if (colorTrack->isColorBigBed)
         color = bedColorToGfxColor(lf->filterColor);
     else
         color = colorTrack->ixAltColor;
 
     for (sf = lf->components; sf != NULL; sf = sf->next)
 	{
 	x1 = round((double)((int)sf->start-winStart)*scale);
 	x2 = round((double)((int)sf->end-winStart)*scale);
 	if(x1 < 0)
 	    x1 = 0;
 	if(x2 > colSize)
 	    x2 = colSize;
 	if(x1 == x2)
 	    x2++;
+        if ((x1 >= colSize) || (x2 >= colSize))
+            break;
 	for(i = x1; i < x2; i++)
             colArray[i] = color;
 	}
     }
 }
 
 static void wigFillInColorBedArray(struct track *wigTrack, Color *colArray, int colSize,
 				  struct track *colorTrack, struct hvGfx *hvg)
 /* Fill in a color array with the simple bed based colorTrack's
    color where it would normally have an block. */
 {
 struct bed *bed = NULL, *bedList = colorTrack->items;
 double scale = scaleForPixels(colSize);
 int x1 = 0, x2 = 0;
 int i = 0;