From efbcb3dec17e7e327db6b7ce20bc3c0dfe9bc986 Mon Sep 17 00:00:00 2001 From: "jfrancis%netscape.com" Date: Mon, 2 Apr 2001 06:09:44 +0000 Subject: [PATCH] bug 58281: fixing mem leaks when shuffling nsISupports around in editor paste code. r=fm; sr=kin git-svn-id: svn://10.0.0.236/trunk@91029 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsHTMLDataTransfer.cpp | 16 ++++++++-------- .../editor/libeditor/html/nsHTMLDataTransfer.cpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mozilla/editor/base/nsHTMLDataTransfer.cpp b/mozilla/editor/base/nsHTMLDataTransfer.cpp index a7f65f9a7a4..d6894dc2b59 100644 --- a/mozilla/editor/base/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/base/nsHTMLDataTransfer.cpp @@ -259,7 +259,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr // but if not we want to delete _contents_ of cells and replace // with non-table elements. Use cellSelectionMode bool to // indicate results. - nsCOMPtr isupports = nodeList->ElementAt(0); + nsCOMPtr isupports = dont_AddRef(nodeList->ElementAt(0)); nsCOMPtr firstNode( do_QueryInterface(isupports) ); if (!nsHTMLEditUtils::IsTableElement(firstNode)) cellSelectionMode = PR_FALSE; @@ -315,7 +315,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr // build up list of parents of first node in lst that are either: // lists, or tables. - nsCOMPtr isup = nodeList->ElementAt(0); + nsCOMPtr isup = dont_AddRef(nodeList->ElementAt(0)); nsCOMPtr pNode( do_QueryInterface(isup) ); nsCOMPtr listAndTableArray; res = NS_NewISupportsArray(getter_AddRefs(listAndTableArray)); @@ -344,7 +344,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr nodeList->Count(&listCount); for (j=0; j isupports = nodeList->ElementAt(j); + nsCOMPtr isupports = dont_AddRef(nodeList->ElementAt(j)); nsCOMPtr curNode( do_QueryInterface(isupports) ); NS_ENSURE_TRUE(curNode, NS_ERROR_FAILURE); @@ -391,13 +391,13 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr // table or list contents outside the table or list. if (highWaterMark >= 0) { - nsCOMPtr isupports = listAndTableArray->ElementAt(highWaterMark); + nsCOMPtr isupports = dont_AddRef(listAndTableArray->ElementAt(highWaterMark)); nsCOMPtr curNode( do_QueryInterface(isupports) ); nsCOMPtr replaceNode, tmp; if (nsHTMLEditUtils::IsTable(curNode)) { // look upward from curNode for a piece of this table - isup = nodeList->ElementAt(0); + isup = dont_AddRef(nodeList->ElementAt(0)); pNode = do_QueryInterface(isup); while (pNode) { @@ -418,7 +418,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr else // list case { // look upward from curNode for a piece of this list - isup = nodeList->ElementAt(0); + isup = dont_AddRef(nodeList->ElementAt(0)); pNode = do_QueryInterface(isup); while (pNode) { @@ -445,7 +445,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr // so that we dont insert them twice. do { - isupports = nodeList->ElementAt(1); + isupports = dont_AddRef(nodeList->ElementAt(1)); tmp = do_QueryInterface(isupports); if (tmp && nsHTMLEditUtils::IsDescendantOf(tmp, replaceNode)) nodeList->RemoveElementAt(1); @@ -461,7 +461,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr nodeList->Count(&listCount); for (j=0; j isupports = nodeList->ElementAt(j); + nsCOMPtr isupports = dont_AddRef(nodeList->ElementAt(j)); nsCOMPtr curNode( do_QueryInterface(isupports) ); NS_ENSURE_TRUE(curNode, NS_ERROR_FAILURE); diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index a7f65f9a7a4..d6894dc2b59 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -259,7 +259,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr // but if not we want to delete _contents_ of cells and replace // with non-table elements. Use cellSelectionMode bool to // indicate results. - nsCOMPtr isupports = nodeList->ElementAt(0); + nsCOMPtr isupports = dont_AddRef(nodeList->ElementAt(0)); nsCOMPtr firstNode( do_QueryInterface(isupports) ); if (!nsHTMLEditUtils::IsTableElement(firstNode)) cellSelectionMode = PR_FALSE; @@ -315,7 +315,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr // build up list of parents of first node in lst that are either: // lists, or tables. - nsCOMPtr isup = nodeList->ElementAt(0); + nsCOMPtr isup = dont_AddRef(nodeList->ElementAt(0)); nsCOMPtr pNode( do_QueryInterface(isup) ); nsCOMPtr listAndTableArray; res = NS_NewISupportsArray(getter_AddRefs(listAndTableArray)); @@ -344,7 +344,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr nodeList->Count(&listCount); for (j=0; j isupports = nodeList->ElementAt(j); + nsCOMPtr isupports = dont_AddRef(nodeList->ElementAt(j)); nsCOMPtr curNode( do_QueryInterface(isupports) ); NS_ENSURE_TRUE(curNode, NS_ERROR_FAILURE); @@ -391,13 +391,13 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr // table or list contents outside the table or list. if (highWaterMark >= 0) { - nsCOMPtr isupports = listAndTableArray->ElementAt(highWaterMark); + nsCOMPtr isupports = dont_AddRef(listAndTableArray->ElementAt(highWaterMark)); nsCOMPtr curNode( do_QueryInterface(isupports) ); nsCOMPtr replaceNode, tmp; if (nsHTMLEditUtils::IsTable(curNode)) { // look upward from curNode for a piece of this table - isup = nodeList->ElementAt(0); + isup = dont_AddRef(nodeList->ElementAt(0)); pNode = do_QueryInterface(isup); while (pNode) { @@ -418,7 +418,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr else // list case { // look upward from curNode for a piece of this list - isup = nodeList->ElementAt(0); + isup = dont_AddRef(nodeList->ElementAt(0)); pNode = do_QueryInterface(isup); while (pNode) { @@ -445,7 +445,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr // so that we dont insert them twice. do { - isupports = nodeList->ElementAt(1); + isupports = dont_AddRef(nodeList->ElementAt(1)); tmp = do_QueryInterface(isupports); if (tmp && nsHTMLEditUtils::IsDescendantOf(tmp, replaceNode)) nodeList->RemoveElementAt(1); @@ -461,7 +461,7 @@ nsresult nsHTMLEditor::InsertHTMLWithCharsetAndContext(const nsString& aInputStr nodeList->Count(&listCount); for (j=0; j isupports = nodeList->ElementAt(j); + nsCOMPtr isupports = dont_AddRef(nodeList->ElementAt(j)); nsCOMPtr curNode( do_QueryInterface(isupports) ); NS_ENSURE_TRUE(curNode, NS_ERROR_FAILURE);