mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Make ReplaceObjectAt a little safer. Bug 227780, r=timeless, sr=alecf
This commit is contained in:
parent
7550832d25
commit
8a516c2bc7
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user