Closed Bug 297584 Opened 20 years ago Closed 20 years ago

MS IE profile migration code casts LPWSTR to |char *| and treats the result as UTF-8

Categories

(Firefox :: Migration, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jshin1987, Assigned: jshin1987)

Details

Attachments

(1 file, 1 obsolete file)

http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/urlhist/structs/staturl.asp

|pwcsurl| of STATURL struct is LPWSTR, but it's cast to |char *| and the result
is treated as UTF-8. 

http://lxr.mozilla.org/seamonkey/source/browser/components/migration/src/nsIEProfileMigrator.cpp#557

556           // 3 - URL
557           url = statURL.pwcsUrl;
558 
559           nsDependentCString urlStr((const char *) url);

I wonder how this has ever worked....
Attached patch patch (obsolete) — Splinter Review
With this patch, I don't get any more assertion in 'UTF8 -> UTF-16 converter'
and IE history items are imported properly.
 
Btw, there may be a memory leak here because MSDN says that 'STATURL->p..url'
should be freeed by a caller, but we don't. I'll see if there's indeed a leak
in another bug.
Attachment #186182 - Flags: superreview?(darin)
Attachment #186182 - Flags: review?(mconnor)
Could this possibly be the cause of bug 235495?
Ah, reading bug 235495 comment 10 and this patch seems to indicate that is not
the case. Sorry about that, please disregard.
Comment on attachment 186182 [details] [diff] [review]
patch 

Looks good.  Do we need to worry about the memory leak?
Attachment #186182 - Flags: superreview?(darin) → superreview+
Thanks for sr. I confirmed that there are indeed memory leaks and I just
decided to fill them up in this bug.
Attachment #186182 - Attachment is obsolete: true
Attachment #186315 - Flags: superreview?(darin)
Attachment #186315 - Flags: review?(cbiesinger)
Attachment #186182 - Flags: review?(mconnor)
Comment on attachment 186315 [details] [diff] [review]
update (fixes memory leaks as well)

ohh, fun :)
Attachment #186315 - Flags: review?(cbiesinger) → review+
Attachment #186315 - Flags: superreview?(darin) → superreview+
Comment on attachment 186315 [details] [diff] [review]
update (fixes memory leaks as well)

asking for a. 
this is a low risk patch that fixes the string handling in MS IE history
importing code.
Attachment #186315 - Flags: approval-aviary1.1a2?
Attachment #186315 - Flags: approval-aviary1.1a2? → approval-aviary1.1a2+
landed on the trunk with the following line moved outside |if (|stat.pwcsUrl|)|
just in case statURL.pwcsTitle is non-null for null stat.pwcsURL.

+          if (statURL.pwcsTitle) 
+            ::CoTaskMemFree(statURL.pwcsTitle);
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: