Skip to content

Commit

Permalink
livecheck: Stop on negative regexp offset
Browse files Browse the repository at this point in the history
If the given regex is an empty string, regexp returns indices {0 -1}.
This -1 was taken as the offset where to start applying the regex again,
leading to an infinite loop handling the same line over and over.

(cherry picked from commit d33a8a0)
  • Loading branch information
raimue authored and jmroot committed Feb 2, 2017
1 parent f00e996 commit 0f192fe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/port1.0/portlivecheck.tcl
Expand Up @@ -172,7 +172,7 @@ proc portlivecheck::livecheck_main {args} {
set updated_version 0
while {[gets $chan line] >= 0} {
set lastoff 0
while {[regexp -start $lastoff -indices $the_re $line offsets]} {
while {$lastoff >= 0 && [regexp -start $lastoff -indices $the_re $line offsets]} {
regexp -start $lastoff $the_re $line matched upver
set foundmatch 1
if {$updated_version == 0 || [vercmp $upver $updated_version] > 0} {
Expand Down

0 comments on commit 0f192fe

Please sign in to comment.