The wizard turns into a hen intending to eat the boy, but the grain changes into a polecat which then bites the hen's head off.
The transformation of a wizard into a hen to eat a boy is countered by a change in grain to a polecat that bites off the hen's head.