* might be after the last newline, if there
* is one, or might be at the start
*/
- for (k = m[j].al; k > 0; k--)
+ for (k = m[j].al; k > 0; k--) {
+ if (m[j].a + k >= af.elcnt)
+ /* FIXME impossible!*/
+ break;
if (ends_line(af.list[m[j].a+k-1])) {
if (firstk > m[j].al)
firstk = k;
break;
}
}
+ }
if (k > 0)
m[j].hi = k;
else if (j == 0)
if (m[i].type == End)
break;
}
- for (k = 1; k < m[i].al; k++)
+ for (k = 1; k < m[i].al; k++) {
+ if (m[i].a + k >= af.elcnt)
+ /* FIXME this should be impossible, but
+ * it happened.
+ */
+ break;
if (words || ends_line(af.list[m[i].a+k])) {
if (unmatched)
unmatched--;
if (extraneous)
extraneous--;
}
+ }
}
if (!show_wiggles)
*wigglesp = wiggles;
int offset)
{
int lines = 0;
- while (len > 0) {
+ while (len > 0 && start < f->elcnt) {
struct elmnt e = f->list[start];
printword(out, e);
if (e.start[e.plen-1] == '\n' &&