From bd5dd2b95bb17a07d1400d677e80c0514fef69d0 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 13 Jan 2019 16:22:19 +0100 Subject: [PATCH] nimgrep: fixes #989 --- tools/nimgrep.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/nimgrep.nim b/tools/nimgrep.nim index 8c6353e319..b26d862b6a 100644 --- a/tools/nimgrep.nim +++ b/tools/nimgrep.nim @@ -160,7 +160,7 @@ proc processFile(pattern; filename: string; counter: var int) = var reallyReplace = true while i < buffer.len: let t = findBounds(buffer, pattern, matches, i) - if t.first < 0: break + if t.first < 0 or t.last < t.first: break inc(line, countLines(buffer, i, t.first-1)) var wholeMatch = buffer.substr(t.first, t.last)