Bug 1336011 - Fix Crash in InvalidArrayIndex_CRASH in mozilla::EditorBase::DeleteSelectionImpl

* EditorBase shouldn't refer mActionListeners directly in loops because it might be removed during a loop
* Create an alias of the type of mEditorObservers
* Create an alias of the type of mDocStateListeners

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-15 01:55:25 -04:00 committed by Roy Tam
commit 31048968fd
2 changed files with 124 additions and 71 deletions

View file

@ -987,11 +987,17 @@ protected:
RefPtr<TextComposition> mComposition;
// Listens to all low level actions on the doc.
nsTArray<OwningNonNull<nsIEditActionListener>> mActionListeners;
typedef AutoTArray<OwningNonNull<nsIEditActionListener>, 5>
AutoActionListenerArray;
AutoActionListenerArray mActionListeners;
// Just notify once per high level change.
nsTArray<OwningNonNull<nsIEditorObserver>> mEditorObservers;
typedef AutoTArray<OwningNonNull<nsIEditorObserver>, 3>
AutoEditorObserverArray;
AutoEditorObserverArray mEditorObservers;
// Listen to overall doc state (dirty or not, just created, etc.).
nsTArray<OwningNonNull<nsIDocumentStateListener>> mDocStateListeners;
typedef AutoTArray<OwningNonNull<nsIDocumentStateListener>, 1>
AutoDocumentStateListenerArray;
AutoDocumentStateListenerArray mDocStateListeners;
// Cached selection for AutoSelectionRestorer.
SelectionState mSavedSel;