Proposed patch; I'll write a ChangeLog entry if it's accepted. The added call to obstack_free() will pop the top allocation off the obstack, which just succeeded before the last one failed. It's just to keep things clean.
--- src/kwset.c 2005-07-04 01:14:37 -0400 +++ src/kwset.c 2005-07-04 09:39:09 -0400 @@ -176,7 +176,10 @@ kwsincr (kwset_t kws, char const *text, link->trie = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie)); if (!link->trie) - return _("memory exhausted"); + { + obstack_free(&kwset->obstack, link); + return _("memory exhausted"); + } link->trie->accepting = 0; link->trie->links = NULL; link->trie->parent = trie; @@ -397,6 +400,8 @@ kwsprep (kwset_t kws) /* Looking for just one string. Extract it from the trie. */ kwset->target = obstack_alloc(&kwset->obstack, kwset->mind); + if (!kwset->target) + return _("memory exhausted"); for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i) { kwset->target[i] = curr->links->label;