diff options
author | Denys Vlasenko | 2009-12-04 02:48:14 +0100 |
---|---|---|
committer | Denys Vlasenko | 2009-12-04 02:48:14 +0100 |
commit | 6dc0ace10943b9f8e004b63277dc1186594f0450 (patch) | |
tree | fbfea896312234df57f330e16629c246a660aea0 /findutils | |
parent | 6a110c969f357d5ab3503660c6404a1ee9d916eb (diff) | |
download | busybox-6dc0ace10943b9f8e004b63277dc1186594f0450.zip busybox-6dc0ace10943b9f8e004b63277dc1186594f0450.tar.gz |
grep: fix a case when -o loops forever
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'findutils')
-rw-r--r-- | findutils/grep.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index 776a629..9dc2f19 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -229,8 +229,8 @@ static int grep_file(FILE *file) char *line = NULL; ssize_t line_len; size_t line_alloc_len; -#define rm_so start[0] -#define rm_eo end[0] +# define rm_so start[0] +# define rm_eo end[0] #endif #if ENABLE_FEATURE_GREP_CONTEXT int print_n_lines_after = 0; @@ -238,7 +238,7 @@ static int grep_file(FILE *file) int idx = 0; /* used for iteration through the circular buffer */ #else enum { print_n_lines_after = 0 }; -#endif /* ENABLE_FEATURE_GREP_CONTEXT */ +#endif while ( #if !ENABLE_EXTRA_COMPAT @@ -377,6 +377,8 @@ static int grep_file(FILE *file) print_line(line + gl->matched_range.rm_so, end - gl->matched_range.rm_so, linenum, ':'); + if (old == '\0') + break; line[end] = old; #if !ENABLE_EXTRA_COMPAT if (regexec(&gl->compiled_regex, line + end, |