Fixes #5186

(cherry picked from commit 25e333a39b3f808723db69e55c2826877e76a22c)