Can you try with the patch from the commit referenced above?
If works, it will be backported to stable branches, however note that 5.1.x is no longer maintained by Kamailio project, you would have to upgrade to 5.3 or 5.4, otherwise backport the patch to your local clone.