Mercurial > hg > octave-lyh > gnulib-hg
changeset 16472:3aacf1725823
regex: re_search etc. should return -2 when memory exhausted
This bug was uncovered when testing 'grep'. Without the fix,
re_search and friends return -1 when memory is exhausted, but -1
means no match, and this causes grep to falsely report no-match
instead of memory-exhaustion. See
<http://sources.redhat.com/bugzilla/show_bug.cgi?id=13762>.
* lib/regexec.c (re_search_stub): Return -2 (not -1) if there is
trouble; this can occur if re_search_internal ran out of memory.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sun, 26 Feb 2012 23:09:05 -0800 |
parents | 1f4605f1f3ae |
children | 5d99cc3818ef |
files | ChangeLog lib/regexec.c |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2012-02-26 Paul Eggert <eggert@cs.ucla.edu> + + regex: re_search etc. should return -2 when memory exhausted + This bug was uncovered when testing 'grep'. Without the fix, + re_search and friends return -1 when memory is exhausted, but -1 + means no match, and this causes grep to falsely report no-match + instead of memory-exhaustion. See + <http://sources.redhat.com/bugzilla/show_bug.cgi?id=13762>. + * lib/regexec.c (re_search_stub): Return -2 (not -1) if there is + trouble; this can occur if re_search_internal ran out of memory. + 2012-02-26 Bruno Haible <bruno@clisp.org> modfl-ieee: Work around test failures on IRIX, OSF/1, mingw.
--- a/lib/regexec.c +++ b/lib/regexec.c @@ -475,7 +475,7 @@ /* I hope we needn't fill ther regs with -1's when no match was found. */ if (result != REG_NOERROR) - rval = -1; + rval = result == REG_NOMATCH ? -1 : -2; else if (regs != NULL) { /* If caller wants register contents data back, copy them. */