[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] regex: re_search etc. should return -2 when memory exhausted
From: |
Paul Eggert |
Subject: |
[PATCH] regex: re_search etc. should return -2 when memory exhausted |
Date: |
Sun, 26 Feb 2012 23:11:14 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
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.
---
ChangeLog | 11 +++++++++++
lib/regexec.c | 2 +-
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ed9c384..433609a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-02-26 Paul Eggert <address@hidden>
+
+ 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 <address@hidden>
modfl-ieee: Work around test failures on IRIX, OSF/1, mingw.
diff --git a/lib/regexec.c b/lib/regexec.c
index 660d25b..5cbfa91 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -475,7 +475,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
/* 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. */
--
1.7.6.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] regex: re_search etc. should return -2 when memory exhausted,
Paul Eggert <=