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:
buster%netscape.com 1999-09-19 23:47:04 +00:00
parent 4f7990cd94
commit 8ad67117c7
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;