Closed
Bug 267611
Opened 20 years ago
Closed 17 years ago
get rid of malloc/copy/free sequence in nsStandardURL::Init
Categories
(Core :: Networking, defect)
Core
Networking
Tracking
()
RESOLVED
FIXED
People
(Reporter: bryner, Assigned: bryner)
References
Details
(Keywords: perf)
Attachments
(1 file)
|
2.67 KB,
patch
|
darin.moz
:
review+
|
Details | Diff | Splinter Review |
Currently, if |charset| is "UTF-*", we hit a pretty bad case for string operations in nsStandardURL::Init. We'll malloc a heap buffer for mOriginCharset, copy the given string into it, then free the buffer once we see that it starts with "UTF". Much better to figure that out _before_ messing with mOriginCharset.
| Assignee | ||
Comment 1•20 years ago
|
||
| Assignee | ||
Updated•20 years ago
|
Attachment #164519 -
Flags: review?(darin)
Comment 2•20 years ago
|
||
Comment on attachment 164519 [details] [diff] [review] patch >Index: nsStandardURL.cpp >+// URI can't be encoded in UTF-16, UTF-16BE, UTF-16LE, UTF-32, UTF-32-LE, >+// UTF-32LE, UTF-32BE (yet?). Truncate mOriginCharset if it starts with >+// "utf" (since an empty mOriginCharset implies UTF-8, this is safe even if >+// mOriginCharset is UTF-8). >+ >+inline PRBool >+IsUTFCharset(const char *aCharset) moving the comment above this function doesn't quite make sense. i think the comment should stay down where we actually assign mOriginCharset. >+ if (mOriginCharset.Length() >= 3 && >+ IsUTFCharset(mOriginCharset.get())) { >+ mOriginCharset.Truncate(); I think you can safely check mOriginCharset.Length() > 3 since "UTF" should be accompanied by a suffix. >+ else { >+ if (!IsUTFCharset(charset)) { >+ mOriginCharset = charset; >+ } >+ } nit: you could write: else if (!IsUTFCharset(charset)) mOriginCharset = charset; r=darin with those nits fixed.
Attachment #164519 -
Flags: review?(darin) → review+
Comment 3•20 years ago
|
||
I think this caused the crash in bug 271196.
| Assignee | ||
Updated•18 years ago
|
Assignee: bryner → nobody
QA Contact: benc → networking
Comment 4•18 years ago
|
||
Shouldn't this be marked FIXED?
Comment 5•17 years ago
|
||
This got checked in a LONG time ago and the only regression it caused is also long fixed. Marking FIXED.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Updated•17 years ago
|
Assignee: nobody → bryner
You need to log in
before you can comment on or make changes to this bug.
Description
•