2093b34d5abc0f995acd69d28f83a60afaa3f966 angie Wed May 15 17:11:04 2019 -0700 Prevent bigWarn methods from crashing if given a NULL or empty error message. refs #22440 note 130 diff --git src/hg/hgTracks/bigWarn.c src/hg/hgTracks/bigWarn.c index a7489ae..e155262 100644 --- src/hg/hgTracks/bigWarn.c +++ src/hg/hgTracks/bigWarn.c @@ -4,38 +4,42 @@ * See README in this or parent directory for licensing information. */ #include "common.h" #include "hgTracks.h" #include "container.h" #include "bigWarn.h" #include "hgConfig.h" static int bigWarnNumLines(char *errMsg) /* Count number of lines in err msg */ { int n = countChars(errMsg, '\n'); int sl = strlen(errMsg); if ((sl > 0) && (errMsg[sl-1]!='\n')) ++n; +if (n == 0) + n = 1; return n; } char *bigWarnReformat(char *errMsg) /* Return a copy of the re-formatted error message, * such as breaking longer lines */ { +if (errMsg == NULL) + return cloneString(""); /* convert ". " to ".\n" to break long lines. */ char *result = cloneString(errMsg); char *nl = result; while ((nl = strchr(nl,'.'))) { ++nl; if (nl[0] == ' ') { nl[0] = '\n'; ++nl; } } return result; }