Include upstream GitHub Pull Request #352 to fix RC bug

Bring existing pull request by Jelmer Vernooij <jelmer> that has
been submitted upstream but has not been accepted yet in order to
work around the critical error. Will remove this patch when either
upstream accepts or provides a better fix.

Thanks: Jelmer Vernooij <jelmer>
Closes: #750517, #755910