Ivanovic survives scare