3.0 : Fix Hash not returning correct value with special paths

Refs to #4574, only for the 3.0 branch. Stumbled upon the same problem.
Same fix as in #4575 was applied.

I don't know if there will be some kind of big magical merge of this kind of stuff before releasing 3.0, so if it's useless, feel free to close this.