Closed Bug 393294 Opened 17 years ago Closed 17 years ago

nsDOMPopupBlockedEvent leaks an nsWeakReference

Categories

(Core :: DOM: Events, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sayrer, Unassigned)

References

()

Details

(Keywords: memory-leak)

Attachments

(3 files)

Attached file comptr leak
Pretty much any site that tries to open a popup seems to trigger this leak.
Keywords: mlk
Attached patch Fix.Splinter Review
This is untested, but should fix this leak.
Attachment #277808 - Flags: superreview?(dbaron)
Attachment #277808 - Flags: review?(sayrer)
And the attached patch should also make us not leak the nsString members in nsPopupBlockedEvent too.
While I'm for some reason unable to get gdb to break when we hit this code, I do know for a fact that this code does run (yay for good ol' printf()). Given that, this should fix this leak.
Attachment #277808 - Flags: review?(sayrer) → review?(Olli.Pettay)
Attachment #277808 - Flags: review?(Olli.Pettay) → review+
nsBeforePageUnloadEvent has an nsString member and nsCommandEvent has an nsCOMPtr<nsIAtom> member.
Attachment #277881 - Flags: superreview?(jst)
Attachment #277881 - Flags: review?(jst)
Comment on attachment 277881 [details] [diff] [review]
fix 2 other possible leaks

 class nsDOMCommandEvent : public nsDOMEvent,
                           public nsIDOMCommandEvent
 {
 public:
   nsDOMCommandEvent(nsPresContext* aPresContext,
                     nsCommandEvent* aEvent);
+  ~nsDOMCommandEvent();

Might as well explicitly state here that this is virtual while you're at it.

r+sr+a=jst
Attachment #277881 - Flags: superreview?(jst)
Attachment #277881 - Flags: superreview+
Attachment #277881 - Flags: review?(jst)
Attachment #277881 - Flags: review+
Attachment #277881 - Flags: approval1.9+
Checked in the patch 2 (added |virtual|)
 nsDOMBeforeUnloadEvent::~nsDOMBeforeUnloadEvent() 
 {
+  if (mEventIsInternal &&
+      mEvent->eventStructType == NS_BEFORE_PAGE_UNLOAD_EVENT) {
+      delete static_cast<nsBeforePageUnloadEvent*>(mEvent);
+      mEvent = nsnull;
+  }
 }

Nit: incorrectly indented body
Attachment #277808 - Flags: superreview?(dbaron) → superreview+
Attachment #277808 - Flags: approval1.9+
Fix checked in. (and fixed the indentation issue pointed out by jag as well.)
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Heh, you unindented the wrapped part of the |if| condition. I re-indented that for you.
Duh. Thanks Jag!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: