From 7a932125e9f5022f7514ecd5d809ddc2f810a6cc Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Wed, 17 Jun 2020 13:07:15 +0000 Subject: [PATCH] Bug 1645246 - fluent shouldn't release-crash if one translation clobbers another element listed for translation, r=zbraniecki,smaug See https://bugzilla.mozilla.org/show_bug.cgi?id=1645246#c4 for what causes the crash. I'm avoiding translating as well as attempting to update prototypes for disconnected elements, which I've verified fixes the crash. Differential Revision: https://phabricator.services.mozilla.com/D79508 --- dom/l10n/DOMLocalization.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dom/l10n/DOMLocalization.cpp b/dom/l10n/DOMLocalization.cpp index b7e4cd4fe978..8b10893f25a0 100644 --- a/dom/l10n/DOMLocalization.cpp +++ b/dom/l10n/DOMLocalization.cpp @@ -485,6 +485,14 @@ bool DOMLocalization::ApplyTranslations( hasMissingTranslation = true; continue; } + // If we have a proto, we expect all elements are connected up. + // If they're not, they may have been removed by earlier translations. + // We will have added an error in L10nOverlays in this case. + // This is an error in fluent use, but shouldn't be crashing. There's + // also no point translating the element - skip it: + if (aProto && !elem->IsInComposedDoc()) { + continue; + } L10nOverlays::TranslateElement(*elem, aTranslations[i].Value(), errors, aRv); if (NS_WARN_IF(aRv.Failed())) {