化险为夷

化險為夷
huàxiǎnwéi
to turn peril into safety (idiom); to avert disaster

CEDICT

Entry Composition