Closed
Bug 413488
Opened 17 years ago
Closed 16 years ago
nsACString::Find in nsStringAPI is buggy!
Categories
(Core :: XPCOM, defect, P1)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla1.9beta4
People
(Reporter: prasad, Assigned: prasad)
Details
Attachments
(2 files)
2.64 KB,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
2.25 KB,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
Code from: http://lxr.mozilla.org/mozilla/source/xpcom/glue/nsStringAPI.cpp#710 710 nsACString::Find(const self_type& aStr, PRUint32 aOffset, 711 ComparatorFunc c) const 712 { 713 const char_type *begin; 714 PRUint32 len = aStr.BeginReading(&begin); 715 716 if (aOffset > len) 717 return -1; 718 719 PRInt32 found = Find(begin + aOffset, len - aOffset, c); 720 if (found == -1) 721 return found; 722 723 return found + aOffset; 724 } The Find function above is supposed to find aStr starting at aOffset on this string. But the code above seems to something completely wrong! The other function Find being called inside this actually finds a "char *" of a given length in this string. The attached patch fixes it and also makes minor (and silly) changes in a couple of other places.
Attachment #298460 -
Flags: review?(benjamin)
Assignee | ||
Updated•17 years ago
|
Summary: nsACString::Find(const self_type& aStr ... code is buggy! → nsACString::Find in nsStringAPI is buggy!
Comment 1•17 years ago
|
||
Comment on attachment 298460 [details] [diff] [review] Fixes nsACString::Find function This is ok, but it must have a unit test before landing.
Attachment #298460 -
Flags: review?(benjamin) → review+
Comment 2•17 years ago
|
||
I think this should block beta4, as a serious error in the frozen string API.
Flags: blocking1.9?
Priority: -- → P1
Comment 4•16 years ago
|
||
This is a mismatch between the new frozen string API and the old nonfrozen one, so it's effectively a regression for extension authors.
Keywords: checkin-needed
Comment 5•16 years ago
|
||
As per comment #1, this needs a unit test before it can land.
Flags: in-testsuite?
Keywords: checkin-needed
Assignee | ||
Comment 6•16 years ago
|
||
This patch adds test cases for the Find function in nsStringAPI. Apart from being a test case for this bug, it has test cases to test few other use cases of the Find functions too.
Attachment #302256 -
Flags: review?(benjamin)
Updated•16 years ago
|
Attachment #302256 -
Flags: review?(benjamin) → review+
Updated•16 years ago
|
Keywords: checkin-needed
Comment 7•16 years ago
|
||
Checking in xpcom/glue/nsStringAPI.cpp; /cvsroot/mozilla/xpcom/glue/nsStringAPI.cpp,v <-- nsStringAPI.cpp new revision: 3.11; previous revision: 3.10 done Checking in xpcom/tests/TestStringAPI.cpp; /cvsroot/mozilla/xpcom/tests/TestStringAPI.cpp,v <-- TestStringAPI.cpp new revision: 1.3; previous revision: 1.2 done
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9beta4
You need to log in
before you can comment on or make changes to this bug.
Description
•