Closed Bug 9069 Opened 25 years ago Closed 25 years ago

nsStr::RFindCharInSet loops forever if destination not found

Categories

(Core :: XPCOM, defect, P3)

All
Windows NT
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: hjtoi-bugzilla, Assigned: rickg)

References

()

Details

(Whiteboard: [07301999] waiting to hear back from heikki@citec.fi)

The summary really says it all, but the reason is that we have an unsigned integer that we are decrementing which means our loop will never terminate if a searched character is not found. PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnoreCase,PRUint32 anOffset) { PRUint32 offset=aDest.mLength-anOffset; // <= unsigned! PRInt32 thePos; while(--offset>=0) { // <= offset can never be < 0! PRUnichar theChar=GetCharAt(aDest,offset); thePos=gRFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase) ; if(kNotFound!=thePos) return offset; } //while return kNotFound; } Also, the person fixing this bug should take a look at the usage of *int* and *int32* in nsStr. My understanding is that we should use PRInt16/32!
Assignee: dp → rickg
Status: NEW → ASSIGNED
This is fixed in my tree, and will land with my next update.
The fix has been checked in.
Status: ASSIGNED → NEW
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Whiteboard: [07301999] waiting to hear back from heikki@citec.fi
Marking verified.
Status: RESOLVED → VERIFIED
This is what vacation does to you: sloppiness. NOW it should be verified...
You need to log in before you can comment on or make changes to this bug.