Andy Murray survived a scare to battle past an inspired Paolo Lorenzi into the fourth round of the US Open, while Juan Martin del Potro saw off David Ferrer in straight sets.