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,8 +1130,9 @@ 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 ) ) {
edge += dict->nodeSize;
PatMatch match = {0}; PatMatch match = {0};
if ( nextPeerMatch( iter, &edge, &match, log ) ) { if ( nextPeerMatch( iter, &edge, &match, log ) ) {
pushEdge( iter, edge, &match ); /* let the top of the loop examine this one */ pushEdge( iter, edge, &match ); /* let the top of the loop examine this one */
@ -1140,6 +1141,7 @@ nextWord( DictIter* iter, XP_Bool log )
} }
} }
} }
}
if ( success && !!iter->indexer ) { if ( success && !!iter->indexer ) {
(*iter->indexer->proc)(iter->indexer->closure); (*iter->indexer->proc)(iter->indexer->closure);