]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
fix infinite loop in debug_regexp
authorRasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
Thu, 22 Jan 2015 12:29:54 +0000 (13:29 +0100)
committerRasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
Thu, 22 Jan 2015 12:29:54 +0000 (13:29 +0100)
autorandr.py

index c7aa86623b29503d9e60aad794543a159d5792c8..18381df0fff950a2713030c4afe99bf3354c07ba 100755 (executable)
@@ -278,6 +278,8 @@ def debug_regexp(pattern, string):
         bounds = ( 0, len(string) )
         while bounds[0] != bounds[1]:
             half = int((bounds[0] + bounds[1]) / 2)
+            if half == bounds[0]:
+                break
             bounds = (half, bounds[1]) if regex.search(pattern, string[:half], partial=True) else (bounds[0], half - 1)
         partial_length = bounds[0]
         return ("Regular expression matched until position "