I occasionally have leg cramps while swimming- I never felt I was in danger though. Is it really that dangerous? I'm talking about painful cramps where I really can't use the leg that's cramping before a few minutes go by. Generally what I do is swear the air purple (it really bloody hurts) and try to keep the cramping leg extended (it's normally the muscle in the back of my tibia that cramps and it wants to draw my heel back, so I push the other way until it gives up). I thrash a lot and go under the water for sure, but I can still swimm with the remaining limbs. I don't know what I'd do if both legs cramped at the same time, but one leg so far I've been able to handle.
Edit: now that I think of it, I've had both legs cramp, except not at the same time- a few minutes apart. I was getting used to very long flippers (fins?) and I got two cramps a few minutes apart, one in each leg.