FYI I believe this patch is equivalent to a commit that has already been merged into master: