Backport of patch to bug 439591