Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ulrich Weigand <weigand@i1.informatik.uni-erlangen.de>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] Fix invalid use of va_list
Date: Tue, 30 Mar 2004 13:36:00 -0000	[thread overview]
Message-ID: <200403301336.PAA17124@faui1d.informatik.uni-erlangen.de> (raw)

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


             reply	other threads:[~2004-03-30 13:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-30 13:36 Ulrich Weigand [this message]
2004-03-30 15:44 ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200403301336.PAA17124@faui1d.informatik.uni-erlangen.de \
    --to=weigand@i1.informatik.uni-erlangen.de \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox