c089010fe023fc7c73b6eb93aabacccfe52a1aaa braney Tue Nov 5 17:00:18 2024 -0800 fix a problem that happened when we were at the last element of the color array diff --git src/hg/hgTracks/wigTrack.c src/hg/hgTracks/wigTrack.c index d423c62..c13d722 100644 --- src/hg/hgTracks/wigTrack.c +++ src/hg/hgTracks/wigTrack.c @@ -68,38 +68,43 @@ double scale = scaleForPixels(colSize); int x1 = 0, x2 = 0; int i = 0; for(lf = lfList; lf != NULL; lf = lf->next) { unsigned color; 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); + + // make sure x1 is at least zero and not greater than the array size if(x1 < 0) x1 = 0; - if(x2 > colSize) - x2 = colSize; + else if (x1 > colSize) + break; + + // make sure x2 is at least one bigger than x1 and that it's not bigger than the array if(x1 == x2) x2++; - if ((x1 >= colSize) || (x2 >= colSize)) - break; + if(x2 > colSize) + x2 = colSize; + 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;