This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: patch for crash in d-lang.c's demangler
- From: Tom Tromey <tromey at redhat dot com>
- To: Brad Roberts <braddr at puremagic dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 10 Aug 2010 16:16:34 -0600
- Subject: Re: patch for crash in d-lang.c's demangler
- References: <4C55E1CE.5000301@puremagic.com>
>>>>> "Brad" == Brad Roberts <braddr@puremagic.com> writes:
Brad> There's a minor, but important bug in the d language symbol
Brad> demangler. I haven't reviewed the whole thing for other bugs,
Brad> just the one that I hit.
Thanks.
Brad> I don't have a copyright assignment form on file, but hopefully
Brad> this diff is small enough to not require one.
Yes, I agree.
I think your patch is reasonable, but the line just after your change is
weird:
> if (i <= 0 && strlen (mangled_str) < i)
> return 0;
I don't think that condition can ever be true.
What do you think of this patch, instead?
Tom
*** d-lang.c.~1.1.~ 2010-04-29 08:45:38.000000000 -0600
--- d-lang.c 2010-08-10 16:14:51.000000000 -0600
***************
*** 37,45 ****
while (isdigit (*mangled_str))
{
! i = strtol (mangled_str, NULL, 10);
! mangled_str++;
! if (i <= 0 && strlen (mangled_str) < i)
return 0;
obstack_grow (tempbuf, mangled_str, i);
mangled_str += i;
--- 37,47 ----
while (isdigit (*mangled_str))
{
! char *end_ptr;
!
! i = strtol (mangled_str, &end_ptr, 10);
! mangled_str = end_ptr;
! if (i <= 0 || strlen (mangled_str) < i)
return 0;
obstack_grow (tempbuf, mangled_str, i);
mangled_str += i;