You cannot create a correct nsPromiseFlatString on a Substring. Specifically, nsPromiseFlatString does not detect the case where the Substring does not end at the right-most character of the "parent" string. Here's a simple example: const nsAReadableCString& hereIsSomeText = NS_LITERAL_CSTRING("here is some text"); const nsAReadableCString& some = Substring(hereIsSomeText, 8, 4); printf("%s\n", nsPromiseFlatCString(some).get()); Expected output: some Actual output: some text
cc'ing vidur, who worked on nsPromiseFlatString...
Need this for RTM? /be
promise-flat needs some work ... needs to know about non-zero terminated cases, etc.
(mass change) didn't get these in for target milestone mozilla0.8.1 but they are very close. Moving all to mozilla0.9.
Hey scc, when are you going to fix this?
So this is fixed at the cost of always copying substrings even when that is _not_ required. I'm going to do more work on substrings to prevent this. Basically, they have to advertise themselves as flat at the appropriate time. Currently, they never do. Marking this bug fixed.