If there is no money, then there is no money. What happens quite often is that some of her or his colleagues help out by hiring deserving students instead till extra funding has been found. This has the advantage that it diminished the risk everybody faces because of uncertain funding, but it requires quite a bit of trust and good will in the department. So the worst case scenario, that the professor has no money and nobody wants to help her or him out, can definitely happen.
This also depends on the contract you have. In my case I got a 5 year contract to do my dissertation and some teaching. In that case, my position was safe: if somehow the professor's funding somehow failed the university had to come up with the difference, since the contract was not between the professor's lab and me, but between the university and me. This is in line with @IanSudbery s comment that, however much professors think of "their" lab as her or his private kingdom, it is only part of the university and not a separate entitiy. The fact that the university is finally responsible for paying the wages meant that the university required my professor to have guarantees for the funding for those five years before agreeing on the contract.