re_search out-of-memory patch

Paul Eggert eggert@cs.ucla.edu
Fri Jun 27 19:46:00 GMT 2014


Attached is a patch I'm proposing here by popular request, taken from 
BZ#13762.
-------------- next part --------------
2012-02-27  Paul Eggert  <eggert@cs.ucla.edu>

	* posix/regexec.c (re_search_stub): Return -2, not -1, on
	memory exhaustion.

diff --git a/posix/regexec.c b/posix/regexec.c
index ec4ae13..74232ab 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -466,7 +466,7 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
 
   /* 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.  */


More information about the Libc-alpha mailing list