Index: Source/core/editing/ReplaceSelectionCommand.cpp |
diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp |
index 90ce127d8175518ea113edf0d4ef5e271a199cf5..984c9e076fe29414f4fb19e8cf5871a0575167d2 100644 |
--- a/Source/core/editing/ReplaceSelectionCommand.cpp |
+++ b/Source/core/editing/ReplaceSelectionCommand.cpp |
@@ -665,12 +665,12 @@ void ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds(InsertedNodes& ins |
{ |
document().updateLayoutIgnorePendingStylesheets(); |
- Node& lastLeafInserted = insertedNodes.lastLeafInserted(); |
- if (lastLeafInserted.isTextNode() && !nodeHasVisibleRenderText(toText(lastLeafInserted)) |
- && !enclosingNodeWithTag(firstPositionInOrBeforeNode(&lastLeafInserted), selectTag) |
- && !enclosingNodeWithTag(firstPositionInOrBeforeNode(&lastLeafInserted), scriptTag)) { |
- insertedNodes.willRemoveNode(lastLeafInserted); |
- removeNode(&lastLeafInserted); |
+ Node* lastLeafInserted = insertedNodes.lastLeafInserted(); |
+ if (lastLeafInserted && lastLeafInserted->isTextNode() && !nodeHasVisibleRenderText(toText(*lastLeafInserted)) |
+ && !enclosingNodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), selectTag) |
+ && !enclosingNodeWithTag(firstPositionInOrBeforeNode(lastLeafInserted), scriptTag)) { |
+ insertedNodes.willRemoveNode(*lastLeafInserted); |
+ removeNode(lastLeafInserted); |
} |
// We don't have to make sure that firstNodeInserted isn't inside a select or script element, because |
@@ -1143,7 +1143,7 @@ void ReplaceSelectionCommand::doApply() |
// Setup m_startOfInsertedContent and m_endOfInsertedContent. This should be the last two lines of code that access insertedNodes. |
m_startOfInsertedContent = firstPositionInOrBeforeNode(insertedNodes.firstNodeInserted()); |
- m_endOfInsertedContent = lastPositionInOrAfterNode(&insertedNodes.lastLeafInserted()); |
+ m_endOfInsertedContent = lastPositionInOrAfterNode(insertedNodes.lastLeafInserted()); |
// Determine whether or not we should merge the end of inserted content with what's after it before we do |
// the start merge so that the start merge doesn't effect our decision. |