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/altSplice/affySplice/altProbes.c src/hg/altSplice/affySplice/altProbes.c
index ab6bb27439c..4758801c293 100644
--- src/hg/altSplice/affySplice/altProbes.c
+++ src/hg/altSplice/affySplice/altProbes.c
@@ -377,31 +377,31 @@
 {
 int i=0;
 warn("altProbes - Match probes to splicing paths and analyze.\n"
      "options are:");
 for(i=0; i<ArraySize(optionSpecs) -1; i++)
     fprintf(stderr, "  -%s -- %s\n", optionSpecs[i].name, optionDescripts[i]);
 errAbort("\nusage:\n   ");
 }
 
 struct splice *ndr2CassTest()
 /* Create a splice for use in testsing. */
 {
 char *string = cloneString("chr14	43771400	43772080	chr14.7822-8.26	2	-	9319	38	43765895,43766921,43767127,43767179,43767304,43767340,43767563,43767611,43767860,43767912,43768199,43768244,43768682,43768786,43768944,43769001,43769182,43769269,43769488,43769549,43770672,43770735,43770929,43771050,43771294,43771356,43771400,43771404,43771700,43771742,43772080,43772161,43773937,43774090,43774093,43774180,43774538,43774609,	0,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,1,3,2,1,3,1,3,1,1,2,2,1,2,	2	{\"chr14\",43771400,43772080,0,2,2,{26,30,},24,31,0,},{\"chr14\",43771400,43772080,0,4,4,{26,28,29,30,},24,31,42,},");
 struct splice *splice = NULL;
 char *words[100];
-chopByWhite(string, words, sizeof(words));
+chopByWhite(string, words, ArraySize(words));
 splice = spliceLoad(words);
 }
 
 struct bed *ndr2BedTest()
 /* Create beds used in testing. */
 {
 char *inc1 = "chr14	43771385	43771715	G6912708@J918653_RC@j_at	0	-	43771385	43771715	0	2	15,15,	0,315,";
 char *skip = "chr14	43771385	43772095	G6912708@J918654_RC@j_at	0	-	43771385	43772095	0	2	15,15,	0,695,";
 char *inc2 = "chr14	43771727	43772095	G6912708@J918655_RC@j_at	0	-	43771727	43772095	0	2	15,15,	0,353,";
 char *gene = "chr14	43765981	43772151	G6912708_RC_a_at	0	-	43765981	43772151	0	9	25,25,25,25,25,25,25,25,43,	0,149,1602,3222,3262,3516,5000,5392,6127,";
 struct bed *bedList = NULL, *bed = NULL;
 char *words[12];
 
 chopByWhite(cloneString(inc1), words, ArraySize(words));
 bed = bedLoadN(words,12);