It turns out, that this bug got fixed upstream independently using a slightly different patch.