CopyRewriter::getNewSource calls itself, with no obvious limit to the amount of allowed recursion. Limit it to recursing once, which should catch the obvious cases without the potential infinite recursion.
Arbitrarily limiting the recursion to one isn't ideal, but I'm not sure what the intended limit is, and there aren't any regression tests for more complicated cases.