As written, the function will access element [30] of a 30-element array.
OK?
2011-03-03 Michael Snyder <msny...@vmware.com> * hashtab.c (higher_prime_index): Prevent array overrun. Index: hashtab.c =================================================================== RCS file: /cvs/src/src/libiberty/hashtab.c,v retrieving revision 1.38 diff -u -p -u -p -r1.38 hashtab.c --- hashtab.c 3 Feb 2011 07:23:59 -0000 1.38 +++ hashtab.c 3 Mar 2011 22:01:08 -0000 @@ -173,9 +173,9 @@ static unsigned int higher_prime_index (unsigned long n) { unsigned int low = 0; - unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]); + unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]) - 1; - while (low != high) + while (low < high) { unsigned int mid = low + (high - low) / 2; if (n > prime_tab[mid].prime)