mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
fixed an error where the out param was not being initialized to null.
This could cause an error in the caller if the caller fails to check the return code as well as the pointer!=null before dereferencing the result.
This commit is contained in:
parent
4f7990cd94
commit
8ad67117c7
@ -167,12 +167,19 @@ NS_IMETHODIMP EditAggregateTxn::GetCount(PRInt32 *aCount)
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::GetTxnAt(PRInt32 aIndex, EditTxn **aTxn)
|
||||
{
|
||||
// preconditions
|
||||
NS_PRECONDITION(aTxn, "null out param");
|
||||
NS_PRECONDITION(mChildren, "bad internal state");
|
||||
|
||||
if (!aTxn) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aTxn = nsnull; // initialize out param as soon as we know it's a valid pointer
|
||||
if (!mChildren) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// get the transaction at aIndex
|
||||
const PRInt32 txnCount = mChildren->Count();
|
||||
if (0>aIndex || txnCount<=aIndex) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
@ -167,12 +167,19 @@ NS_IMETHODIMP EditAggregateTxn::GetCount(PRInt32 *aCount)
|
||||
|
||||
NS_IMETHODIMP EditAggregateTxn::GetTxnAt(PRInt32 aIndex, EditTxn **aTxn)
|
||||
{
|
||||
// preconditions
|
||||
NS_PRECONDITION(aTxn, "null out param");
|
||||
NS_PRECONDITION(mChildren, "bad internal state");
|
||||
|
||||
if (!aTxn) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aTxn = nsnull; // initialize out param as soon as we know it's a valid pointer
|
||||
if (!mChildren) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// get the transaction at aIndex
|
||||
const PRInt32 txnCount = mChildren->Count();
|
||||
if (0>aIndex || txnCount<=aIndex) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
Loading…
Reference in New Issue
Block a user