Fix the other problem reported in PR8582. Testcase and patch by