An infinitely red-shifted photon can no longer have a definable energy. Since the energy of a photon is defined by its frequency, and in this instance the photon will have an infinite wavelength or zero frequency, then one would guess that it has lost all its energy.
This probably will not happen due to the gravitational field of a star. Something like this is unlikely even for a very strong gravitational field, like if the photon was emitted just outside a black hole. If you considered the photon to be emitted from a distance $d$ close to a black hole event horizon then $$\lambda_o \approx \frac{\lambda_0}{\sqrt{d}}$$ where $\lambda_o$ is the wavelength you observe, $\lambda_0$ is the emitted initial wavelength. No matter how small we make $d$, $\lambda_o$ will never be infinite, and even if we made $d=0$ the photon would never escape to begin with.