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/hgc/hgc.c src/hg/hgc/hgc.c
index 8c06da77d2f..2a67c2f4fd7 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -7674,31 +7674,31 @@
     int wordCount = chopByChar(cloneString(item), '|', words, ArraySize(words));
     if (wordCount != 3)
 	errAbort("doPcrResult: expected 3 |-sep'd words but got '%s'", item);
     targetSeqName = words[0];
     if (endsWith(targetSeqName, "__"))
 	targetSeqName[strlen(targetSeqName)-2] = '\0';
     ampStart = atoi(words[1]), ampEnd = atoi(words[2]);
     // use the psl file to find the right primer pair
     pslFileGetPrimers(pslFileName, item, ampStart, ampEnd, &fPrimer, &rPrimer);
     }
 else if (stringIn("_", item))
     {
     // the item name contains the forward and reverse primers
     int maxSplits = 2;
     char *splitQName[maxSplits];
-    int numSplits = chopString(cloneString(item), "_", splitQName, sizeof(splitQName));
+    int numSplits = chopString(cloneString(item), "_", splitQName, ArraySize(splitQName));
     if (numSplits == maxSplits)
         {
         fPrimer = splitQName[0];
         touppers(fPrimer);
         rPrimer = splitQName[1];
         touppers(rPrimer);
         }
     }
 else
     {
     pcrResultGetPrimers(primerFileName, &fPrimer, &rPrimer, NULL);
     }
 printf("<H2>PCR Results (<TT>%s %s</TT>)</H2>\n", fPrimer, rPrimer);
 printf("<B>Forward primer:</B> 5' <TT>%s</TT> 3'<BR>\n", fPrimer);
 printf("<B>Reverse primer:</B> 5' <TT>%s</TT> 3'<BR>\n", rPrimer);