From patchwork Fri Jun 27 19:46:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 1806 Received: (qmail 24154 invoked by alias); 27 Jun 2014 19:46:37 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 24143 invoked by uid 89); 27 Jun 2014 19:46:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: smtp.cs.ucla.edu Message-ID: <53ADCA15.5040905@cs.ucla.edu> Date: Fri, 27 Jun 2014 12:46:29 -0700 From: Paul Eggert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: GNU C Library Subject: re_search out-of-memory patch Attached is a patch I'm proposing here by popular request, taken from BZ#13762. 2012-02-27 Paul Eggert * 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. */