> it's discovered to have an incurable security flaw.
AFAIK, that's not possible. Secure hashing algorithms tend to fracture instead of completely break, so there will be some warning; to change to a new algorithm, simply more than 50% of the Bitcoin miners would have to mine on the chain that relies on that new algorithm, and it thus becomes "voted" in.