Apply fix from upstream commit d6846a9bd792db14f12c78728968315b3c0092f1.