If the ball hits the flagstick you are in exactly the position described in the Original post. If the ball does not hit anything , No problem.
I have been in the situation where the flagstick was stuck in the hole & would not come out. fortunately the putt was off line. since then if I am attending the flag I check to make sure that it will come out when I lift it
BTW when we tried to take the flagstick out the cup came out with it . It took us 10 minutes backing it against a concrete sand bin to loosen it so that the cup came of the stick.
I've had that problem, too. But newer flagsticks have grooves down the plug so sand doesn't jam it in.
Along the lines of this thread, if the cup liner is protruding from the hole and your putt hits it, the stroke is replayed without poo enalty.