From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12801 invoked by alias); 14 Oct 2010 15:21:47 -0000 Received: (qmail 12788 invoked by uid 22791); 14 Oct 2010 15:21:46 -0000 X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL,BAYES_20,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Oct 2010 15:21:41 +0000 Received: from md2.u-strasbg.fr (md2.u-strasbg.fr [IPv6:2001:660:2402::187]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o9EFLb1k091049 for ; Thu, 14 Oct 2010 17:21:38 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms8.u-strasbg.fr [IPv6:2001:660:2402:d::17]) by md2.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id o9EFLb3s072901 for ; Thu, 14 Oct 2010 17:21:37 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id o9EFLbZH088644 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Thu, 14 Oct 2010 17:21:37 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: Subject: [PATCH] Avoid pascal crashes for structures having fields without names Date: Thu, 14 Oct 2010 15:21:00 -0000 Message-ID: <000001cb6bb3$7fa6d8b0$7ef48a10$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: 2010-10/txt/msg00242.txt.bz2 I committed the following patch to GDB cvs HEAD. Some Free Pascal classes seem now to have hidden fields that get no names. This could lead to crashes by calling strcmp with a NULL parameter. Pierre Muller Pascal language support maintainer for GDB ChangeLog entry: 2010-10-14 Pierre Muller * p-lang.c (is_pascal_string_type): Avoid crashes on structures having fields without names. Index: p-lang.c =================================================================== RCS file: /cvs/src/src/gdb/p-lang.c,v retrieving revision 1.55 diff -u -p -r1.55 p-lang.c --- p-lang.c 12 Jul 2010 17:07:11 -0000 1.55 +++ p-lang.c 14 Oct 2010 15:17:54 -0000 @@ -105,8 +105,10 @@ is_pascal_string_type (struct type *type { /* Old Borland type pascal strings from Free Pascal Compiler. */ /* Two fields: length and st. */ - if (TYPE_NFIELDS (type) == 2 + if (TYPE_NFIELDS (type) == 2 + && TYPE_FIELDS (type) [0].name && strcmp (TYPE_FIELDS (type)[0].name, "length") == 0 + && TYPE_FIELDS (type) [1].name && strcmp (TYPE_FIELDS (type)[1].name, "st") == 0) { if (length_pos) @@ -124,7 +126,9 @@ is_pascal_string_type (struct type *type /* GNU pascal strings. */ /* Three fields: Capacity, length and schema$ or _p_schema. */ if (TYPE_NFIELDS (type) == 3 + && TYPE_FIELDS (type) [0].name && strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0 + && TYPE_FIELDS (type) [1].name && strcmp (TYPE_FIELDS (type)[1].name, "length") == 0) { if (length_pos)