File port-recent-fix-to-older-pcre-version.patch of Package grep.35702
From 5610ec0ddb5db823ea3164d60a85064fd8f1aae6 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 10 Sep 2014 00:04:58 -0700
Subject: [PATCH] grep: port recent fix to older pcre version
* src/pcresearch.c (Pexecute): Don't assume that a pcre_exec
that returns PCRE_ERROR_NOMATCH leaves its sub argument alone.
This assumption is false for libpcre-3 version 8.31-2ubuntu2.
---
src/pcresearch.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/pcresearch.c b/src/pcresearch.c
index 2a01e6d..4e2ccf8 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -157,14 +157,16 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
/* Treat encoding-error bytes as data that cannot match. */
for (;;)
{
+ int valid_bytes;
e = pcre_exec (cre, extra, p, line_end - p, 0, options, sub, nsub);
if (e != PCRE_ERROR_BADUTF8)
break;
- e = pcre_exec (cre, extra, p, sub[0], 0,
+ valid_bytes = sub[0];
+ e = pcre_exec (cre, extra, p, valid_bytes, 0,
options | PCRE_NO_UTF8_CHECK, sub, nsub);
if (e != PCRE_ERROR_NOMATCH)
break;
- p += sub[0] + 1;
+ p += valid_bytes + 1;
options = PCRE_NOTBOL;
}
--
2.35.3