I can’t find a saying meaning exactly what you’re looking for. The best match is probably “Je l’ai échappée belle”. But this sentence is used when a danger is menacing you and finally chooses another target or simply misses. For instance, if someone shoots at you and you duck and avoid the bullet, you could say “je l’ai échapée belle”. It has the same meaning as “j’ai eu chaud” which is more familiar.
Another saying could be “Le malheur des uns fait le bonheur des autres”. In this case, it means that one person benefits from the misfortune of another.