Fixes #5387

(cherry picked from commit fcc679385cdc222e961938244864469dbc48993d)