2nd try at fix Issue 12989
Merge pull request #3739 from WalterBright/fix12989-2

2nd try at fix Issue 12989