Although in these situations one may hold on to a coral, one's best solution (rather than a temporary one) would be to simply calmly ascend.
Grabbing on to a coral and then subsequently getting stung will do little to ease the situation. Some coral will break off, again, doing nothing to assist.
Get out of a life threatening situation by establishing positive bouyancy, inflating the bc and dropping the weights if necessary.
I agree that human life is a higher priority, but holding onto coral in the above situations do not solve the problem, and may in fact exacerbate the problem, if the diver grabs on to the wrong species of coral!