From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22610 invoked by alias); 23 Jan 2012 16:03:34 -0000 Received: (qmail 22600 invoked by uid 22791); 23 Jan 2012 16:03:33 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 16:03:14 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0NG3D8n016975 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Jan 2012 11:03:13 -0500 Received: from host2.jankratochvil.net (ovpn-116-21.ams2.redhat.com [10.36.116.21]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0NG397f028730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 23 Jan 2012 11:03:12 -0500 Date: Mon, 23 Jan 2012 16:09:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] find_and_open_script: Fix failed fdopen Message-ID: <20120123160309.GA25174@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00773.txt.bz2 Hi, just noticed if fdopen fails find_and_open_script returns generally invalid result. I just read the code, not seen in practice. No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu. I will check it in. Thanks, Jan gdb/ 2012-01-23 Jan Kratochvil * cli/cli-cmds.c (find_and_open_script): Handle failure of fdopen. --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -513,6 +513,17 @@ find_and_open_script (const char *script_file, int search_path, do_cleanups (old_cleanups); *streamp = fdopen (fd, FOPEN_RT); + if (*streamp == NULL) + { + int save_errno = errno; + + if (full_pathp) + xfree (*full_pathp); + do_cleanups (old_cleanups); + errno = save_errno; + return 0; + } + return 1; }