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: Andreas Schwab <schwab at linux-m68k dot org>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Joel Brobecker <brobecker at adacore dot com>, gdb-patches at sourceware dot org
- Date: Sun, 22 Jul 2012 21:40:55 +0200
- Subject: Re: creating the gdb-7.4 branch tomorrow (?)
- References: <20111205081911.GG28486@adacore.com> <m34nxdoawj.fsf@fleche.redhat.com>
Tom Tromey <tromey@redhat.com> writes:
> +static void
> +filter_sals (struct symtabs_and_lines *sals)
> +{
> + int i, out, prev;
> +
> + out = 0;
> + for (i = 0; i < sals->nelts; ++i)
> + {
> + if (sals->sals[i].pspace == current_program_space
> + || sals->sals[i].symtab == NULL)
> + {
> + sals->sals[out] = sals->sals[i];
> + ++out;
> + }
> + }
> + sals->nelts = out;
> +
> + qsort (sals->sals, sals->nelts, sizeof (struct symtab_and_line),
> + compare_symtabs);
> +
> + out = 1;
> + prev = 0;
> + for (i = 1; i < sals->nelts; ++i)
> + {
> + if (compare_symtabs (&sals->sals[prev], &sals->sals[i]))
> + {
> + /* Symtabs differ. */
> + sals->sals[out] = sals->sals[i];
> + prev = out;
> + ++out;
> + }
> + }
> + sals->nelts = out;
> +
> + if (sals->nelts == 0)
This is never true. If sals->nelts == 0 on entry then it will always be
set to 1, causing the caller to crash when dereferencing sals->sals.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."