Avoid memory overruns for big regular expressions