Conditions for the vanishing of the genus-2 G-function