Make ReplaceObjectAt a little safer. Bug 227780, r=timeless, sr=alecf

git-svn-id: svn://10.0.0.236/trunk@150902 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2004-01-05 23:43:28 +00:00
parent 4a7fde8018
commit d615bdff68

View File

@@ -115,8 +115,9 @@ nsCOMArray_base::ReplaceObjectAt(nsISupports* aObject, PRInt32 aIndex)
// ReplaceElementAt could fail, such as if the array grows
// so only release the existing object if the replacement succeeded
if (result) {
NS_IF_RELEASE(oldObject);
// Make sure to addref first, in case aObject == oldObject
NS_IF_ADDREF(aObject);
NS_IF_RELEASE(oldObject);
}
return result;
}