From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] Avoid pascal crashes for structures having fields without names
Date: Thu, 14 Oct 2010 15:21:00 -0000 [thread overview]
Message-ID: <000001cb6bb3$7fa6d8b0$7ef48a10$@muller@ics-cnrs.unistra.fr> (raw)
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 <muller@ics.u-strasbg.fr>
* 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)
next reply other threads:[~2010-10-14 15:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-14 15:21 Pierre Muller [this message]
[not found] <35800.5107882947$1287069713@news.gmane.org>
2010-10-14 17:48 ` Tom Tromey
2010-10-15 15:44 ` Pierre Muller
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='000001cb6bb3$7fa6d8b0$7ef48a10$@muller@ics-cnrs.unistra.fr' \
--to=pierre.muller@ics-cnrs.unistra.fr \
--cc=gdb-patches@sourceware.org \
/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