Closed Bug 190879 Opened 22 years ago Closed 13 years ago

FindChar() should assert and return kNotFound if called with offset > string length

Categories

(Core :: XPCOM, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: sspitzer, Assigned: jag+mozilla)

Details

FindChar() should assert and return kNotFound if called with offset > string 
length

see http://bugzilla.mozilla.org/show_bug.cgi?id=187065 for an example of this.

of course, callers shouldn't be doing this.

but can we add some code to assert and bail on this?
Should that code be debug only? I'd rather we fix all callers than burden
everyone with this check.
QA Contact: scc → string
I checked and found that all the string (nsTSubstring.cpp, nsStringAPI.cpp) are checking for offset < length and are returning -1 (kNotFound) if found.

http://mxr.mozilla.org/mozilla-central/source/xpcom/string/src/nsTSubstring.cpp#675
http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsStringAPI.cpp#875

I guess this bug has been fixed and hence marking it as Resolved/WorksForMe.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
Feel free to open in case you found the problem in the existing code (which I missed).
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.