轉危為安

Idiom

 * 1) to transform peril into safety; to avert a danger