e5c2df7918c8e87602d4a525636dfcf6a2f77076 max Mon Jun 16 08:02:09 2025 -0700 making code a little nicer, refs #34157 diff --git src/lib/errAbort.c src/lib/errAbort.c index 6892861615f..19e64660806 100644 --- src/lib/errAbort.c +++ src/lib/errAbort.c @@ -41,37 +41,39 @@ boolean debugPushPopErr; // generate stack dump on push/pop error boolean errAbortInProgress; /* Flag to indicate that an error abort is in progress. * Needed so that a warn handler can tell if it's really * being called because of a warning or an error. */ WarnHandler warnArray[maxWarnHandlers]; int warnIx; AbortHandler abortArray[maxAbortHandlers]; int abortIx; }; static struct perThreadAbortVars *getThreadVars(); // forward declaration static void defaultVaWarn(char *format, va_list args) /* Default error message handler. */ { -if (format != NULL) { +if (format == NULL) + return; + if (doContentType) { - // Need to destroy < and > in format AND args, to make XSS impossible. puts("Content-type: text/html\n"); puts("Error: "); + // Need to destroy < and > in format AND args, to make XSS impossible. va_list args_copy; // first output message to stderr, as before va_copy(args_copy, args); // vfprintf() & co cannot be called twice in a row without a va_copy vfprintf(stderr, format, args); va_end(args_copy); va_copy(args_copy, args); int needed = vsnprintf(NULL, 0, format, args_copy); // get size of buffer va_end(args_copy); if (needed < 0) { puts("defaultVaWarn - string format error in errAbort"); // Formatting error return; } @@ -92,31 +94,30 @@ } fputs(buffer, stdout); // output buffer fprintf(stdout, "\n"); fflush(stdout); free(buffer); } else { // normal case, for command line tools or browsers where showEarlyWarnings is not set in hg.conf fflush(stdout); vfprintf(stderr, format, args); fprintf(stderr, "\n"); fflush(stderr); } } -} static void silentVaWarn(char *format, va_list args) /* Warning handler that just hides it. Useful sometimes when high level code * expects low level code may fail (as in finding a file on the net) but doesn't * want user to be bothered about it. */ { } void vaWarn(char *format, va_list args) /* Call top of warning stack to issue warning. */ { struct perThreadAbortVars *ptav = getThreadVars(); ptav->warnArray[ptav->warnIx](format, args); }