This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun
- From: DJ Delorie <dj at redhat dot com>
- To: Michael Snyder <msnyder at vmware dot com>
- Cc: gcc-patches at gcc dot gnu dot org, gdb-patches at sourceware dot org
- Date: Thu, 3 Mar 2011 17:11:09 -0500
- Subject: Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun
- References: <4D701056.1080208@vmware.com>
> As written, the function will access element [30] of a 30-element array.
Um, no?
unsigned int mid = low + (high - low) / 2;
This can never give mid == high unless low == high, which won't happen
in that loop.
The math wants to search everything from (including) low to
(excluding) high.
(but I'm willing to be proven wrong...)