It's false without any additional assumptions. I'm guessing that g is supposed to be continuous in this exercise. The general fact is that two continuous functions which agree on a dense subset are the same function (at least when the codomain is a reasonable space, which R certainly is).

Here's a hint for showing it in this particular case: suppose g(x) is nonzero for some x. Then...hmm...I don't think I can say anything further without giving it all away. Use continuity.