Fix bug #18982. Thanks to John Darrington for investigation,