This is not really the right fix, `g_return_*if_fail()` is supposed to catch programming error, to check the contract between the caller and the callee. Admittedly here the values are accessed before the contract is checked, which is probably worth fixing, but the bug itself is that these functions get called with values they are not supposed to.