From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3666 invoked by alias); 30 Mar 2004 13:36:41 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 3644 invoked from network); 30 Mar 2004 13:36:34 -0000 Received: from unknown (HELO faui10.informatik.uni-erlangen.de) (131.188.31.10) by sources.redhat.com with SMTP; 30 Mar 2004 13:36:34 -0000 Received: from faui1d.informatik.uni-erlangen.de (faui1d [131.188.31.34]) by faui10.informatik.uni-erlangen.de (8.9.3p3/8.1.9-FAU) with ESMTP id PAA19796 for ; Tue, 30 Mar 2004 15:36:32 +0200 (CEST) From: Ulrich Weigand Received: (from weigand@localhost) by faui1d.informatik.uni-erlangen.de (8.9.3p3/8.1.6-FAU) id PAA17124 for gdb-patches@sources.redhat.com; Tue, 30 Mar 2004 15:36:32 +0200 (CEST) Message-Id: <200403301336.PAA17124@faui1d.informatik.uni-erlangen.de> Subject: [PATCH] Fix invalid use of va_list To: gdb-patches@sources.redhat.com Date: Tue, 30 Mar 2004 13:36:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2004-03/txt/msg00745.txt.bz2 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