Closed Bug 479057 Opened 15 years ago Closed 15 years ago

Prefixing a string to an empty autostring causes an extra pointless copy

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1
Tracking Status
status1.9.1 --- .10-fixed

People

(Reporter: neil, Assigned: neil)

Details

Attachments

(2 files)

Steps to reproduce problem:
1. Start a debug build
2. Turn off keyword.enabled
3. Try to load ://
Actual result: ###!!! ASSERTION: buffer incorrectly sized: 'a.Length() == headLen', file nsTSubstringTuple.cpp, line 78

What's happening here is that nsDefaultURIFixup strips off the bogus :// and attempts to prefix http:// in its place. It does this using

uriString.Assign(NS_LITERAL_CSTRING("http://") + uriString);

We create a substring tuple from "http://" and [R]uriString, and decide that [L]uriString doesn't depend on it, so that we can write to it in place. So we adjust [L]uriString's length, and then try to copy [R]uriString and "http://". Of course since [L]uriString and [R]uriString are the same thing, we've just changed [R]uriString's length which is why we get confused as to what to copy.
We actually copy "http://" to uriString, and then uriString to uriString.
This test fails with our current code.
Attached patch Confident patchSplinter Review
Passes the test :-)
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #362917 - Flags: review?(benjamin)
Assignee: neil → nobody
Component: XPCOM → String
QA Contact: xpcom → string
Assignee: nobody → neil
Attachment #362917 - Flags: review?(benjamin) → review+
Pushed changeset 6c0ff682551d to mozilla-central.

Actually I pushed it yesterday. See bug 478732 for the gory details.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Attachment #362917 - Flags: approval1.9.1.10?
would we not want this on the 1.9.2 branch if it's good for the 1.9.1 branch?
It landed before 1.9.2 branched.
Comment on attachment 362917 [details] [diff] [review]
Confident patch

a=beltzner for 1.9.1.10
Attachment #362917 - Flags: approval1.9.1.10? → approval1.9.1.10+
Pushed changeset 9a06693cdbb4 to releases/mozilla-1.9.1
Target Milestone: --- → mozilla1.9.2a1
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: