Suppose a public company has 1,000,000 authorized shares, of which 400,000 have been issued. The company starts a share-buyback program and buys 100,000 shares. So there are now 100,000 shares in the treasury, and 300,000 in the public's hands. Suppose a few years later, the company decides that it needs cash and decides to sell shares. When it sells shares (e.g. using a rights issue, or to a private equity firm), will those shares come from the 100,000 treasury shares, or will those shares come from the 600,000 shares that have never been issued before?
It can do either, or both. There's really no difference from a cash perspective, only a slight difference in how the change in equity is bucketed (Drop in treasury stock vs. an increase in Paid-in Capital).