Skip to content

Commit

Permalink
re: Fix non-termination for a certain regular expression
Browse files Browse the repository at this point in the history
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
  • Loading branch information
msantos authored and bjorng committed Apr 20, 2010
1 parent 09ca69e commit 78a4800
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion erts/emulator/pcre/pcre_exec.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5191,7 +5191,6 @@ for(;;)
EDEBUGF(("Loop limit break detected")); EDEBUGF(("Loop limit break detected"));
return PCRE_ERROR_LOOP_LIMIT; return PCRE_ERROR_LOOP_LIMIT;
RESTART_INTERRUPTED: RESTART_INTERRUPTED:
md->match_call_count = 0;
md->loop_limit = extra_data->loop_limit; md->loop_limit = extra_data->loop_limit;
rc = match(NULL,NULL,NULL,0,md,0,NULL,0,0); rc = match(NULL,NULL,NULL,0,md,0,NULL,0,0);
*extra_data->loop_counter_return = *extra_data->loop_counter_return =
Expand Down

0 comments on commit 78a4800

Please sign in to comment.