A simple Wikipedia lookup for The Golden Bird offers the solution:
The fox removes it, and then, as they set out, he advises the prince how to keep all the things he has won since then. It then asks the prince to shoot it and cut off its head. When the prince refuses, it warns him against buying gallows' flesh and sitting on the edge of rivers.
He finds that his older brothers, who have been carousing and living sinfully in the meantime, are to be hanged (on the gallows) and buys their liberty. They find out what he has done. When he sits on a river's edge, they push him in. They take the things and the princess and bring them to their father. However the bird, the horse, and the princess all grieve for the youngest son. The fox rescues the prince. When he returns to his father's castle dressed in a beggar's cloak, the bird, the horse, and the princess all recognize him as the man who won them, and become cheerful again. His older brothers got punished for their good-less deeds, and he marries the princess.
Apparently, then, to buy "gallows flesh" is to purchase the liberty of those about to be executed on the gallows. The prince ignores the warning and suffers the consequences (though only temporarily).