Aaron Stone wrote:
Crashing on null %s args puts gnulib at odds with all other open source
lib's -- glibc, *BSD libc's, so on. People use gnulib to get the gnuish
behavior on other platforms. Being safe about nulls is a gnuish behavior
that many people appreciate.

Indeed.  Then, sometimes, I do want the seg fault.  So, how about selectable
behavior? :-)  e.g.:

    {
        tSCC zBadArgs[] = "Bad args to sprintf";
        tSCC zBadFmt[]  = "%s ERROR:  %s processing printf format:\n\t%s\n";
        int  faultType  = sigsetjmp( printJumpEnv, 0 );

        /*
         *  IF the asprintfv call below is going to address fault,
         *  THEN ...
         */
        if (faultType != 0) {
            /*
             *  IF the fprintf command in the then clause has not failed yet,
             *  THEN perform that fprintf
             */
            if (sigsetjmp( printJumpEnv, 0 ) == 0)
                fprintf(pfTrace, zBadFmt, pzProg, strsignal(faultType), pzFmt);

            /*
             *  The "sprintfv" command below faulted, so we exit
             */
            AG_ABEND( zBadArgs );
        }
    }
    {
        size_t printSize = asprintfv( ppzBuf, pzFmt,
                                      (snv_constpointer*)argV );


Reply via email to