90dc829b2d87b15c4fc4bbc1d814f83d1274ef52
braney
  Fri Sep 4 14:00:05 2026 -0700
Pass element counts, not byte sizes, to the chop routines

chopByWhite, chopString and chopByChar take their last argument as a
count of elements in the output array.  Fifteen call sites passed
sizeof(array) instead.  For an array of pointers that is eight times
the real capacity on a 64-bit build, so the chop could write well past
the end of the array.

Switched each to ArraySize().  Behaviour is unchanged for any input
that already fitted in the array.

Built clean: lib, hg/lib, hg/hgTracks, hg/hgc, hg/utils/hubCheck,
utils/bedScore, parasol/lib, parasol/parasol.  Three directories do not
build, but they fail the same way without this change: checkExp is
missing htslib link flags, and cgapSageFind and affySplice have stale
prototypes in files this does not touch.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

diff --git src/hg/hgTracks/bedTrack.c src/hg/hgTracks/bedTrack.c
index 907215bbe48..7fc36d9f323 100644
--- src/hg/hgTracks/bedTrack.c
+++ src/hg/hgTracks/bedTrack.c
@@ -1000,31 +1000,31 @@
 tg->items = simpleBedListToLinkedFeatures(tg->items, tg->bedSize, TRUE, TRUE);
 }
 
 
 static Color itemColorByStrand(struct track *tg, int orientation, struct hvGfx *hvg)
 /* Look up the RGB color from the trackDb setting 'colorByStrand' based on
  * the orientation (1='+', 0=unknown, -1='-'), and convert this to a color index
  * using hvGfx */
 {
 char *words[3];
 unsigned char r, g, b;
 
 char *colors = cloneString(trackDbSetting(tg->tdb, "colorByStrand"));
 if (!colors)
     errAbort("colorByStrand setting missing (in %s)", tg->track);
-if (chopByWhite(colors, words, sizeof(words)) != 2)
+if (chopByWhite(colors, words, ArraySize(words)) != 2)
     errAbort("invalid colorByStrand setting %s (expecting pair of RGB values r,g,b r,g,b)", colors);
 if (orientation == 1)
     parseColor(words[0], &r, &g, &b);
 else if (orientation == -1)
     parseColor(words[1], &r, &g, &b);
 else // return the main color
     {
     r = tg->color.r; g = tg->color.g; b = tg->color.b;
     }
 freez(&colors);
 return hvGfxFindColorIx(hvg, r, g, b);
 }
 
 Color lfItemColorByStrand(struct track *tg, void *item, struct hvGfx *hvg)
 /* Look up the RGB color from the trackDb setting 'colorByStrand' based on