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.


git-svn-id: svn://10.0.0.236/trunk@48285 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
buster%netscape.com
1999-09-19 23:47:04 +00:00
parent 69a8cf7c7b
commit d631159edf
2 changed files with 14 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;