[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] Handling null pointers to printf

From: Bruce Korb
Subject: Re: [bug-gnulib] Handling null pointers to printf
Date: Fri, 26 May 2006 10:35:42 -0700
User-agent: Mozilla Thunderbird 1.0.7 (X11/20050923)

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

[Prev in Thread] Current Thread [Next in Thread]