From e4b461d0b3cfe9958182c2a26d39f6375260d9e9 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 26 Aug 2014 16:13:22 +0300 Subject: [PATCH] Bug 1057677 - Crash in nsHTMLEditor::DoInsertHTMLWithContext; r=ehsan --- editor/libeditor/crashtests/1057677.html | 9 +++++++++ editor/libeditor/crashtests/crashtests.list | 1 + editor/libeditor/nsHTMLDataTransfer.cpp | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 editor/libeditor/crashtests/1057677.html diff --git a/editor/libeditor/crashtests/1057677.html b/editor/libeditor/crashtests/1057677.html new file mode 100644 index 000000000000..d0b9497a5abc --- /dev/null +++ b/editor/libeditor/crashtests/1057677.html @@ -0,0 +1,9 @@ + + diff --git a/editor/libeditor/crashtests/crashtests.list b/editor/libeditor/crashtests/crashtests.list index be753fdc1753..4c78bae5ec8c 100644 --- a/editor/libeditor/crashtests/crashtests.list +++ b/editor/libeditor/crashtests/crashtests.list @@ -58,3 +58,4 @@ needs-focus load 771749.html load 772282.html load 776323.html needs-focus load 793866.html +load 1057677.html diff --git a/editor/libeditor/nsHTMLDataTransfer.cpp b/editor/libeditor/nsHTMLDataTransfer.cpp index 53c24a11afa3..6101f43ad995 100644 --- a/editor/libeditor/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/nsHTMLDataTransfer.cpp @@ -411,9 +411,9 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString, // this is because if there is a br at end of what we paste, it will make // the invisible br visible. nsWSRunObject wsObj(this, parentNode, offsetOfNewNode); - if (nsTextEditUtils::IsBreak(wsObj.mEndReasonNode) && - !IsVisBreak(wsObj.mEndReasonNode) ) - { + if (wsObj.mEndReasonNode && + nsTextEditUtils::IsBreak(wsObj.mEndReasonNode) && + !IsVisBreak(wsObj.mEndReasonNode)) { rv = DeleteNode(wsObj.mEndReasonNode); NS_ENSURE_SUCCESS(rv, rv); }