Thank you for applying the patch, although after discussing with Stefan Monnier on help-gnu-emacs[1], I believe the correct fix should go in Emacs's font-lock.el. font-lock-prepend-text-property should work just as well as font-lock-append-text-property, and my patch relies on undefined behaviour IIUC.
I am currently writing a proper bug report, which I will submit to bug-gnu-emacs. https://lists.gnu.org/archive/html/help-gnu-emacs/2019-04/msg00248.html