Fixes #5485

(cherry picked from commit a0291b0d7aac8b7ae1696d30b7e5dbcd1ec0de3e)