diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 99b5d765e83..9a5e8e323b8 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -1627,6 +1627,7 @@ nsFrameSelection::MaintainSelection(nsSelectionAmount aAmount) PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); mMaintainedAmount = aAmount; + mMaintainRange = nsnull; nsCOMPtr startNode; nsCOMPtr endNode; @@ -1642,7 +1643,9 @@ nsFrameSelection::MaintainSelection(nsSelectionAmount aAmount) rv = mDomSelections[index]->GetFocusOffset(&endOffset); NS_ENSURE_SUCCESS(rv, rv); - mMaintainRange = nsnull; + if (!startNode || !endNode) + return NS_OK; + NS_NewRange(getter_AddRefs(mMaintainRange)); if (!mMaintainRange) return NS_ERROR_OUT_OF_MEMORY;