Uninitialized value of variable BACKREF is referred in EGexecute.  It
does not cause wrong result, but regex may be used even when it is not
needed.  It may lead grep to slowdown.

By the way, gawk initializes the variable already, so it does not have
to be fixed.
From 1103b67eb8cdf02098b09f79d73f26c897e4db96 Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <nori...@kcn.ne.jp>
Date: Tue, 11 Aug 2015 00:37:00 +0900
Subject: [PATCH] grep: avoid use of uninitialized variable

* src/dfasearch.c (EGexecute): Initialize backref.
---
 src/dfasearch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/dfasearch.c b/src/dfasearch.c
index 8b8af06..de51321 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -207,7 +207,6 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
 {
   char const *buflim, *beg, *end, *ptr, *match, *best_match, *mb_start;
   char eol = eolbyte;
-  int backref;
   regoff_t start;
   size_t len, best_len;
   struct kwsmatch kwsm;
@@ -227,6 +226,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
           char const *next_beg, *dfa_beg = beg;
           size_t count = 0;
           bool exact_kwset_match = false;
+          int backref = 0;
 
           /* Try matching with KWset, if it's defined.  */
           if (kwset)
-- 
2.4.6

Reply via email to