This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: asprintf/psignal.c change really correct?


Thorsten Kukuk <kukuk@suse.de> writes:

> Hi,
>
> We have the following change in current glibc CVS.
> I don't think that it is correct: if asprintf fails, we
> use fprintf or fwprintf. But than we access buf and try to
> print the content. But buf is undefined here.

This should work:

2004-06-14  Andreas Schwab  <schwab@suse.de>

	* stdio-common/psignal.c (psignal): Don't use buf when asprintf
	failed.

--- stdio-common/psignal.c	03 Jun 2004 12:59:50 +0200	1.11
+++ stdio-common/psignal.c	14 Jun 2004 20:11:58 +0200	
@@ -64,12 +64,14 @@ psignal (int sig, const char *s)
 	  else
 	    (void) fprintf (stderr, "%s%s%s\n", s, colon, _("Unknown signal"));
 	}
-
-      if (_IO_fwide (stderr, 0) > 0)
-	(void) __fwprintf (stderr, L"%s",  buf);
       else
-	(void) fputs (buf, stderr);
+	{
+	  if (_IO_fwide (stderr, 0) > 0)
+	    (void) __fwprintf (stderr, L"%s",  buf);
+	  else
+	    (void) fputs (buf, stderr);
 
-      free (buf);
+	  free (buf);
+	}
     }
 }

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]