From 78a48004ed9e488de702baa63763ce6e6b602a93 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Tue, 20 Apr 2010 12:12:41 +0200 Subject: re: Fix non-termination for a certain regular expression The following code never terminates: fail() -> Str = "http:/www.flickr.com/slideShow/index.gne?group_id=&user_id=69845378@N0", EMail_regex = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+" ++ "(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" ++ "@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+" ++ "(?:[a-zA-Z]{2}|com|org|net|gov|mil" ++ "|biz|info|mobi|name|aero|jobs|museum)", io:format("about to run...~n"), Ret = re:run(Str, EMail_regex), io:format("Ret is ~p~n", [Ret]). Fix it by having pcre_exec remember match_call_count between restarts. Reported-by: Gordon Guthrie Acked-by: Patrik Nyblom --- erts/emulator/pcre/pcre_exec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/erts/emulator/pcre/pcre_exec.c b/erts/emulator/pcre/pcre_exec.c index 51625130c3..3fe13ca32e 100644 --- a/erts/emulator/pcre/pcre_exec.c +++ b/erts/emulator/pcre/pcre_exec.c @@ -5191,7 +5191,6 @@ for(;;) EDEBUGF(("Loop limit break detected")); return PCRE_ERROR_LOOP_LIMIT; RESTART_INTERRUPTED: - md->match_call_count = 0; md->loop_limit = extra_data->loop_limit; rc = match(NULL,NULL,NULL,0,md,0,NULL,0,0); *extra_data->loop_counter_return = -- cgit v1.2.3