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) diff --git src/hg/hgTracks/pubsTracks.c src/hg/hgTracks/pubsTracks.c index 5869521030a..0287f9dc6ff 100644 --- src/hg/hgTracks/pubsTracks.c +++ src/hg/hgTracks/pubsTracks.c @@ -74,31 +74,31 @@ if (!sqlTableExists(conn, "pubsClassColors")) { return; } char query[1024]; sqlSafef(query, sizeof query, "SELECT class, rgbColor FROM pubsClassColors"); struct sqlResult *sr = sqlGetResult(conn, query); char **row = NULL; while ((row = sqlNextRow(sr)) != NULL) { char *class = row[0]; char *colStr = row[1]; // copied from genePredItemClassColor - is there no function for this? // convert comma sep rgb string to array char *rgbVals[5]; - chopString(colStr, ",", rgbVals, sizeof(rgbVals)); + chopString(colStr, ",", rgbVals, ArraySize(rgbVals)); struct rgbColor *rgb; AllocVar(rgb); rgb->r = (sqlUnsigned(rgbVals[0])); rgb->g = (sqlUnsigned(rgbVals[1])); rgb->b = (sqlUnsigned(rgbVals[2])); //printf("Adding hash: %s -> %d,%d,%d", class, rgb->r, rgb->g, rgb->b); hashAdd(pubsClassColors, cloneString(class), rgb); } sqlFreeResult(&sr); } static char *pubsFeatureLabel(char *author, char *year) /* create label given authors and year strings */ { char *authorYear = NULL;