Closed Bug 225952 Opened 21 years ago Closed 20 years ago

*getter_Copies abuse

Categories

(Core :: XPCOM, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: neil, Assigned: neil)

References

()

Details

Attachments

(2 files, 5 obsolete files)

Two files abuse getter_Copies by assigning into *getter_Copies. At the very
least they should be using Adopt, but the actual uses need rewriting anyway.
when touching objectframe, you could also change this:
978 nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI, 
979                               nsString aSrc,

to use const nsAString& instead of nsString
Attached patch Fix nsObjectFrame.cpp (obsolete) — Splinter Review
Attachment #135709 - Flags: superreview?(jst)
Attachment #135709 - Flags: review?(bz-vacation)
Attached patch Fix gtkmozembed2.cpp (obsolete) — Splinter Review
Attachment #135710 - Flags: superreview?(jst)
Attachment #135710 - Flags: review?(blizzard)
Comment on attachment 135710 [details] [diff] [review]
Fix gtkmozembed2.cpp

>-  if (embedPrivate->mURI.Length()) {
>-    *getter_Copies(embedString) = NEW_TOOLKIT_STRING(embedPrivate->mURI);
>-    retval = strdup(embedString);
>-  }
>+  if (!embedPrivate->mURI.IsEmpty())
>+    retval = NEW_TOOLKIT_STRING(embedPrivate->mURI);

unfortunately this mismatches the allocators... NEW_TOOLKIT_STRING is defined
as either ToNewUTF8String or ToNewCString (see lxr). while i had a hard time
finding callers in the tree of any of the functions you're changing, it does
seem that they want to free the string using g_free. which means you must
allocate it using g_strdup.

so, i would recommend doing something like this...

#define NEW_TOOLKIT_STRING(x) g_strdup(NS_ConvertUTF16toUTF8(x).get())

and accordingly for the ASCII variant. not pretty, but it's correct. :/
Attachment #135710 - Flags: superreview?(jst)
Attachment #135710 - Flags: review?(blizzard)
Attachment #135710 - Flags: review-
Attachment #135709 - Attachment is obsolete: true
Attached patch Better fix for gtkmozembed2.cpp (obsolete) — Splinter Review
Attachment #135710 - Attachment is obsolete: true
Attachment #135716 - Attachment is obsolete: true
Comment on attachment 135714 [details] [diff] [review]
Better fix for nsObjectFrame.cpp

r+sr=bzbarsky.
Attachment #135714 - Flags: superreview+
Attachment #135714 - Flags: review+
Attachment #135709 - Flags: superreview?(jst)
Attachment #135709 - Flags: review?(bz-vacation)
Attachment #135717 - Flags: superreview?(jst)
Attachment #135717 - Flags: review?(blizzard)
Comment on attachment 135717 [details] [diff] [review]
Real better fix for gtkmozembed2.cpp

sr=jst
Attachment #135717 - Flags: superreview?(jst) → superreview+
Comment on attachment 135717 [details] [diff] [review]
Real better fix for gtkmozembed2.cpp

This changes the allocator used for the return values for those functions. 
Please use strdup, if anything.
Attachment #135717 - Flags: review?(blizzard) → review-
Attached patch Updated for review comment (obsolete) — Splinter Review
Attachment #135717 - Attachment is obsolete: true
Comment on attachment 136723 [details] [diff] [review]
Updated for review comment

Assuming jst's sr still applies, re-requesting review.
Attachment #136723 - Flags: superreview+
Attachment #136723 - Flags: review?(blizzard)
The changes in gtkmozembed2 collides with 205425 (it ports gtkmozembed to use
nsEmbedString). I can deal it with it but if we can get a review of that patch
soon maybe it's worth to avoid the conflict.
Depends on: 205425
Transferring jst's sr.
Assignee: string → neil.parkwaycc.co.uk
Attachment #136723 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #171942 - Flags: superreview+
Attachment #171942 - Flags: review?(bryner)
Attachment #171942 - Flags: review?(bryner) → review+
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Attachment #136723 - Flags: review?(blizzard)
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: