This is a regression from Emacs 25, and the fix looks pretty safe to me; although the bug isn't especially severe. Should it go to emacs-26?