South Africa avoided an historic home series whitewash at the hands of New Zealand when Ryan McLaren hit a six off the last ball for a one-wicket win in the final one-day international.