[RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

DJ Delorie dj@redhat.com
Thu Mar 3 22:11:00 GMT 2011


> 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...)



More information about the Gcc-patches mailing list