diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-06-27 14:10:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-27 14:10:49 +0200 |
commit | 9168a0fc95f523c7c852ca95969edb39069f4a03 (patch) | |
tree | d9e7ea0c5086235d0cfa7a7cc34f1760a4d74bb4 /editor/libeditor/TextEditor.cpp | |
parent | a3724697dc38820c4918b9e674ff56d2c15c5bba (diff) | |
parent | 783b60aae187d75c8c1924eceec8c4c56aa40c5e (diff) | |
download | UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.tar UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.tar.gz UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.tar.lz UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.tar.xz UXP-9168a0fc95f523c7c852ca95969edb39069f4a03.zip |
Merge pull request #554 from MoonchildProductions/issue12
Resolve potential null deref crashes in the editor
Diffstat (limited to 'editor/libeditor/TextEditor.cpp')
-rw-r--r-- | editor/libeditor/TextEditor.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp index 8fe824e11..d21585597 100644 --- a/editor/libeditor/TextEditor.cpp +++ b/editor/libeditor/TextEditor.cpp @@ -834,17 +834,19 @@ TextEditor::BeginIMEComposition(WidgetCompositionEvent* aEvent) } nsresult -TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) +TextEditor::UpdateIMEComposition(WidgetCompositionEvent* aCompositionChangeEvent) { - MOZ_ASSERT(aDOMTextEvent, "aDOMTextEvent must not be nullptr"); + MOZ_ASSERT(aCompsitionChangeEvent, + "aCompositionChangeEvent must not be nullptr"); - WidgetCompositionEvent* compositionChangeEvent = - aDOMTextEvent->WidgetEventPtr()->AsCompositionEvent(); - NS_ENSURE_TRUE(compositionChangeEvent, NS_ERROR_INVALID_ARG); - MOZ_ASSERT(compositionChangeEvent->mMessage == eCompositionChange, - "The internal event should be eCompositionChange"); + if (NS_WARN_IF(!aCompositionChangeEvent)) { + return NS_ERROR_INVALID_ARG; + } + + MOZ_ASSERT(aCompositionChangeEvent->mMessage == eCompositionChange, + "The event should be eCompositionChange"); - if (!EnsureComposition(compositionChangeEvent)) { + if (!EnsureComposition(aCompositionChangeEvent)) { return NS_OK; } @@ -865,7 +867,7 @@ TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) MOZ_ASSERT(!mPlaceHolderBatch, "UpdateIMEComposition() must be called without place holder batch"); TextComposition::CompositionChangeEventHandlingMarker - compositionChangeEventHandlingMarker(mComposition, compositionChangeEvent); + compositionChangeEventHandlingMarker(mComposition, aCompositionChangeEvent); NotifyEditorObservers(eNotifyEditorObserversOfBefore); @@ -875,7 +877,7 @@ TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) { AutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName); - rv = InsertText(compositionChangeEvent->mData); + rv = InsertText(aCompositionChangeEvent->mData); if (caretP) { caretP->SetSelection(selection); @@ -887,7 +889,7 @@ TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) // compositionend event, we don't need to notify editor observes of this // change. // NOTE: We must notify after the auto batch will be gone. - if (!compositionChangeEvent->IsFollowedByCompositionEnd()) { + if (!aCompositionChangeEvent->IsFollowedByCompositionEnd()) { NotifyEditorObservers(eNotifyEditorObserversOfEnd); } |