Patchwork re_search out-of-memory patch

login
register
mail settings
Submitter Paul Eggert
Date June 27, 2014, 7:46 p.m.
Message ID <53ADCA15.5040905@cs.ucla.edu>
Download mbox | patch
Permalink /patch/1806/
State New
Headers show

Comments

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

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

Patch

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.  */