Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: Source/core/editing/CompositeEditCommand.cpp

Issue 176863002: Fix null pointer dereference in CompositeEditCommand::moveParagraphs(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename test. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/editing/execCommand/window-open-insert-list-crash-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/CompositeEditCommand.cpp
diff --git a/Source/core/editing/CompositeEditCommand.cpp b/Source/core/editing/CompositeEditCommand.cpp
index d69188eaf5ddfaad342c3372ef2af9ccdb64ca75..fcd66b30e856803be18cb54771c0cd406b222ee4 100644
--- a/Source/core/editing/CompositeEditCommand.cpp
+++ b/Source/core/editing/CompositeEditCommand.cpp
@@ -1234,15 +1234,17 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
applyStyle(styleInEmptyParagraph.get());
if (preserveSelection && startIndex != -1) {
- // Fragment creation (using createMarkup) incorrectly uses regular
- // spaces instead of nbsps for some spaces that were rendered (11475), which
- // causes spaces to be collapsed during the move operation. This results
- // in a call to rangeFromLocationAndLength with a location past the end
- // of the document (which will return null).
- RefPtr<Range> start = PlainTextRange(destinationIndex + startIndex).createRangeForSelection(*document().documentElement());
- RefPtr<Range> end = PlainTextRange(destinationIndex + endIndex).createRangeForSelection(*document().documentElement());
- if (start && end)
- setEndingSelection(VisibleSelection(start->startPosition(), end->startPosition(), DOWNSTREAM, originalIsDirectional));
+ if (Element* documentElement = document().documentElement()) {
+ // Fragment creation (using createMarkup) incorrectly uses regular
+ // spaces instead of nbsps for some spaces that were rendered (11475), which
+ // causes spaces to be collapsed during the move operation. This results
+ // in a call to rangeFromLocationAndLength with a location past the end
+ // of the document (which will return null).
+ RefPtr<Range> start = PlainTextRange(destinationIndex + startIndex).createRangeForSelection(*documentElement);
+ RefPtr<Range> end = PlainTextRange(destinationIndex + endIndex).createRangeForSelection(*documentElement);
+ if (start && end)
+ setEndingSelection(VisibleSelection(start->startPosition(), end->startPosition(), DOWNSTREAM, originalIsDirectional));
+ }
}
}
« no previous file with comments | « LayoutTests/editing/execCommand/window-open-insert-list-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698