Fix bug 5338 -- thanks to Yuya Katayama <yuya999@gmail.com>