Subject: bug#18738: Reference of a uninitialized variable in grep -P

From: Norihiro Tanaka <[email-masked]>
Date: Thu, 16 Oct 2014 08:56:05 +0900

Paul Eggert wrote:
> Thanks for reporting that.  It's a bug in one of the optimizations I
> recently added to work around the libpcre slownesses with UTF-8.
> It's also a bug in our test cases, which should have caught the bug.
> I fixed it with the attached patch.

Thanks for fixing that.

BTW, validation_boundary isn't initialized before pre-searching for an
empty line clearly.  As it's set to 0 (NULL pointer in many machine)
implicitly, it isn't a bug.  However, if you don't avoid to initialize it
by intent, could you consider an attached patch?

From 3b2fb2e866e3a0ba615774f1e790ac6b4ae8f3fb Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <[email-masked]>
Date: Thu, 16 Oct 2014 08:32:57 +0900
Subject: [PATCH] grep: initialized validation_boundary before pre-searching
 for an empty line clearly.

* src/grep.c (main): Initialize validation_boundary before pre-searching
for an empty line clearly.
---
 src/grep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/grep.c b/src/grep.c
index dfc0e51..a0f2620 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2516,6 +2516,7 @@ main (int argc, char **argv)
   /* We need one byte prior and one after.  */
   char eolbytes[3] = { 0, eolbyte, 0 };
   size_t match_size;
+  validated_boundary = eolbytes + 1;
   skip_empty_lines = ((execute (eolbytes + 1, 1, &match_size, NULL) == 0)
                       == out_invert);
 
-- 
2.1.1