Closed Bug 82803 Opened 23 years ago Closed 23 years ago

nsSHEnumerator::HasMoreElements() needs to check mIndex = -1

Categories

(Core Graveyard :: Embedding: APIs, defect, P3)

x86
Windows NT
defect

Tracking

(Not tracked)

VERIFIED FIXED
mozilla1.0

People

(Reporter: depman1, Assigned: radha)

References

()

Details

Attachments

(1 file)

1. Ran mfcEmbed w/ qa tests
2. Ran tests for nsISHistory iface. Incl SH index tests which start at index=0.
3. Special test for SimpleEnumerator.
4. Execute this Code segment:

nsCOMPtr<nsISimpleEnumerator> theSimpleEnum;
rv = theSessionHistory->GetSHistoryEnumerator(getter_AddRefs(theSimpleEnum));

PRBool bMore = PR_FALSE;
nsCOMPtr<nsISupports> nextObj;
nsCOMPtr<nsIHistoryEntry> nextHistoryEntry;
while (NS_SUCCEEDED(theSimpleEnum->HasMoreElements(&bMore)) && bMore)
{
   theSimpleEnum->GetNext(getter_AddRefs(nextObj));
   if (!nextObj)
      continue;
   nextHistoryEntry = do_QueryInterface(nextObj);
   if (!nextHistoryEntry)
      continue;
   rv = nextHistoryEntry->GetURI(getter_AddRefs(theUri));
   rv = theUri->GetSpec(&uriSpec);
   // ...		 
} 

Result: It doesn't execute this while loop because HasMoreElements() initializes 
the mIndex to -1 but only checks between 0 and a positive counter. Also, if I 
replace the while() with a do/while() loop, it will execute, but the last url is 
repeated twice and we get an assert.

Expected: Check for mIndex = -1 in nsSHEnumerator::HasMoreElements(), in the 
"if" condition. Then the code segment will execute. See above url (line 804).
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla1.0
changed qa contact to depstein
QA Contact: mdunn → depstein
The attached patch to nsSHistory.cpp includes patch to bug 84556. Only the last
part of the diffs to line 804, belongs to this bug. The rest belong to bug 84556
r=valeski on the mIndex line change.
sr=rpotts
fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
nsSHEnumerator::HasMoreElements()is now working correctly. tested in testEmbed,
Tests.cpp, CTests::SimpleEnumTest(), using 7/9 build.
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: