Actually that doesn't happen if you sell the entire company that owns the rights which in this case is Sony Entertainment. Sony could sell their film division and not lose the Spidey IP as long as they sell ALL of it, assets and liabilities. What they can't do is sell the Spidey IP by itself.
- - - Updated - - -
One thing that should be mentioned is that Disney has treated Spidey as if it was an internal release. There was no serious competition from the House of the Mouse for 2 weeks in one case and 3 in the other. Piss them off enough and your 1.1 billion B.O. will suddenly shrink to $750-800 million with much of the loss happening in the more profitable North American B.O. as for the first time you face serious competition. Remember Disney mainly does blockbusters these days. Anything serious from them is gonna hurt the bottom line.