Fix infinite-loop risk in fixempties() stage of regex compilation.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 1dd92380b00781b8318d6d3fb2817468e43fe3a5
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2013-03-07T16:51:18Z
Releases: 9.0.13
Fix infinite-loop risk in fixempties() stage of regex compilation.

The previous coding of this function could get into situations where it
would never terminate, because successive passes would re-add EMPTY arcs
that had been removed by the previous pass.  Rewrite the function
completely using a new algorithm that is guaranteed to terminate, and
also seems to be usually faster than the old one.  Per Tcl bugs 3604074
and 3606683.

Tom Lane and Don Porter

Files

PathChange+/−
src/backend/regex/regc_nfa.c modified +245 −69
src/backend/regex/regcomp.c modified +8 −4