From: Rasmus Wriedt Larsen Date: Thu, 22 Jan 2015 12:29:54 +0000 (+0100) Subject: fix infinite loop in debug_regexp X-Git-Tag: 1.0~99^2 X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Fautorandr.git;a=commitdiff_plain;h=29789dfa465985ebd4550518c8e4e47c7d6adebb fix infinite loop in debug_regexp --- diff --git a/autorandr.py b/autorandr.py index c7aa866..18381df 100755 --- a/autorandr.py +++ b/autorandr.py @@ -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 "