fix #8347

backport of 4547cb70699512