This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: creating the gdb-7.4 branch tomorrow (?)
- From: Tom Tromey <tromey at redhat dot com>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: Joel Brobecker <brobecker at adacore dot com>, gdb-patches at sourceware dot org
- Date: Wed, 15 Aug 2012 13:34:28 -0600
- Subject: Re: creating the gdb-7.4 branch tomorrow (?)
- References: <20111205081911.GG28486@adacore.com> <m34nxdoawj.fsf@fleche.redhat.com> <m2vchfr3co.fsf@igel.home>
>>>>> "Andreas" == Andreas Schwab <schwab@linux-m68k.org> writes:
>> +static void
>> +filter_sals (struct symtabs_and_lines *sals)
>> +{
[...]
>> + if (sals->nelts == 0)
Andreas> This is never true. If sals->nelts == 0 on entry then it will
Andreas> always be set to 1, causing the caller to crash when
Andreas> dereferencing sals->sals.
This seems simplest.
Tom
2012-08-15 Tom Tromey <tromey@redhat.com>
* cli/cli-cmds.c (filter_sals): Handle nelts == 0 case.
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 2a80803..5d8a124 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1534,13 +1534,14 @@ filter_sals (struct symtabs_and_lines *sals)
++out;
}
}
- sals->nelts = out;
if (sals->nelts == 0)
{
xfree (sals->sals);
sals->sals = NULL;
}
+ else
+ sals->nelts = out;
}
static void