Thanks, I installed that along with the attached minor refactoring so that the bugfix is in just one place. Closing the bug. I assume that this fix should not be backported into the emacs-26 branch, as the bug is in Emacs 25.