Fixed potential NPE. Reported by Cyprien Quilici.
Merge remote-tracking branch 'upstream/2.2' into 2.2