* asprintf/psignal.c change really correct?
@ 2004-06-14 17:14 Thorsten Kukuk
2004-06-14 18:16 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Kukuk @ 2004-06-14 17:14 UTC (permalink / raw)
To: libc-hacker
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.
Thorsten
--- old/glibc-2.3/stdio-common/psignal.c 2004-03-19 08:30:54.000000000 +0100
+++ new/glibc-2.3/stdio-common/psignal.c 2004-06-14 17:03:29.000000000 +0200
@@ -57,7 +57,13 @@
{
char *buf;
- (void) __asprintf (&buf, _("%s%sUnknown signal %d\n"), s, colon, sig);
+ if (__asprintf (&buf, _("%s%sUnknown signal %d\n"), s, colon, sig) < 0)
+ {
+ if (_IO_fwide (stderr, 0) > 0)
+ (void) __fwprintf (stderr, L"%s%s%s\n", s, colon, _("Unknown signal"));
+ else
+ (void) fprintf (stderr, "%s%s%s\n", s, colon, _("Unknown signal"));
+ }
if (_IO_fwide (stderr, 0) > 0)
(void) __fwprintf (stderr, L"%s", buf);
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE Linux AG Maxfeldstr. 5 D-90409 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: asprintf/psignal.c change really correct?
2004-06-14 17:14 asprintf/psignal.c change really correct? Thorsten Kukuk
@ 2004-06-14 18:16 ` Andreas Schwab
2004-06-15 20:04 ` Roland McGrath
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2004-06-14 18:16 UTC (permalink / raw)
To: Thorsten Kukuk; +Cc: libc-hacker
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."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: asprintf/psignal.c change really correct?
2004-06-14 18:16 ` Andreas Schwab
@ 2004-06-15 20:04 ` Roland McGrath
0 siblings, 0 replies; 3+ messages in thread
From: Roland McGrath @ 2004-06-15 20:04 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Thorsten Kukuk, libc-hacker
> 2004-06-14 Andreas Schwab <schwab@suse.de>
>
> * stdio-common/psignal.c (psignal): Don't use buf when asprintf
> failed.
This is clearly right. I've put it in.
Thanks,
Roland
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-06-15 20:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-14 17:14 asprintf/psignal.c change really correct? Thorsten Kukuk
2004-06-14 18:16 ` Andreas Schwab
2004-06-15 20:04 ` Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).