* [PATCH] Fix invalid use of va_list
@ 2004-03-30 13:36 Ulrich Weigand
2004-03-30 15:44 ` Jim Blandy
0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Weigand @ 2004-03-30 13:36 UTC (permalink / raw)
To: gdb-patches
Hello,
gdb crashes on s390 when the user answers a (y or n) question with
something else. This is caused by the 'query' function reusing a
va_list variable initialized only once multiple times.
This is not allowed according to the C standard (C99 7.15.3), and
in fact doesn't work on platforms that define va_list as an array
type.
The patch below changes query to reinitialize the va_list variable
with va_start before each use.
Tested on s390-ibm-linux.
ChangeLog:
* utils.c (query): Do not use a va_list variable multiple times.
Index: gdb/utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.118
diff -c -p -r1.118 utils.c
*** gdb/utils.c 28 Feb 2004 18:04:37 -0000 1.118
--- gdb/utils.c 30 Mar 2004 12:55:04 -0000
*************** query (const char *ctlstr, ...)
*** 1270,1279 ****
int ans2;
int retval;
- va_start (args, ctlstr);
-
if (query_hook)
{
return query_hook (ctlstr, args);
}
--- 1270,1278 ----
int ans2;
int retval;
if (query_hook)
{
+ va_start (args, ctlstr);
return query_hook (ctlstr, args);
}
*************** query (const char *ctlstr, ...)
*** 1289,1295 ****
--- 1288,1296 ----
if (annotation_level > 1)
printf_filtered ("\n\032\032pre-query\n");
+ va_start (args, ctlstr);
vfprintf_filtered (gdb_stdout, ctlstr, args);
+ va_end (args);
printf_filtered ("(y or n) ");
if (annotation_level > 1)
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Fix invalid use of va_list
2004-03-30 13:36 [PATCH] Fix invalid use of va_list Ulrich Weigand
@ 2004-03-30 15:44 ` Jim Blandy
0 siblings, 0 replies; 2+ messages in thread
From: Jim Blandy @ 2004-03-30 15:44 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
Looks good (obvious). This is not a legally significant change, so
I'll just commit it.
Thanks!
Ulrich Weigand <weigand@i1.informatik.uni-erlangen.de> writes:
> Hello,
>
> gdb crashes on s390 when the user answers a (y or n) question with
> something else. This is caused by the 'query' function reusing a
> va_list variable initialized only once multiple times.
>
> This is not allowed according to the C standard (C99 7.15.3), and
> in fact doesn't work on platforms that define va_list as an array
> type.
>
> The patch below changes query to reinitialize the va_list variable
> with va_start before each use.
>
> Tested on s390-ibm-linux.
>
> ChangeLog:
>
> * utils.c (query): Do not use a va_list variable multiple times.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-03-30 15:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-30 13:36 [PATCH] Fix invalid use of va_list Ulrich Weigand
2004-03-30 15:44 ` Jim Blandy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox