From 29789dfa465985ebd4550518c8e4e47c7d6adebb Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Thu, 22 Jan 2015 13:29:54 +0100 Subject: [PATCH] fix infinite loop in debug_regexp --- autorandr.py | 2 ++ 1 file changed, 2 insertions(+) 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 " -- 2.39.2