fix crash: don't go beyond last edge

An obscure pattern from a user caught this one, but the test should have
been there all along.
This commit is contained in:
Eric House 2020-09-28 18:56:57 -07:00
parent e9ec30206d
commit eb728e4368

View file

@ -1130,13 +1130,15 @@ nextWord( DictIter* iter, XP_Bool log )
we're done, and the top-level while will exit) */ we're done, and the top-level while will exit) */
while ( 0 < iter->nEdges ) { while ( 0 < iter->nEdges ) {
/* remove so isn't part of the match of its peers! */ /* remove so isn't part of the match of its peers! */
array_edge* edge = popEdge( iter ) + dict->nodeSize; array_edge* edge = popEdge( iter );
if ( !IS_LAST_EDGE( dict, edge ) ) {
PatMatch match = {0}; edge += dict->nodeSize;
if ( nextPeerMatch( iter, &edge, &match, log ) ) { PatMatch match = {0};
pushEdge( iter, edge, &match ); /* let the top of the loop examine this one */ if ( nextPeerMatch( iter, &edge, &match, log ) ) {
success = iter->min <= iter->nEdges && ACCEPT_NODE( iter, edge, log ); pushEdge( iter, edge, &match ); /* let the top of the loop examine this one */
break; success = iter->min <= iter->nEdges && ACCEPT_NODE( iter, edge, log );
break;
}
} }
} }
} }