Fixes #5595

(cherry picked from commit b8e81f31d376c184e904f1a3d8d7866a30f67565)