The attached patch solves the issue described here:
More details are available here:
The attached tar-file contains a very small demo package.
This can be used to observe the effect of the patch.
This is all fairly trivial, but I hope useful nonetheless.