nsDocShell::GetDocShellEnumerator leaks docShellEnum in failure cases

RESOLVED FIXED in mozilla1.8alpha4

Status

()

Core
Document Navigation
--
minor
RESOLVED FIXED
14 years ago
14 years ago

People

(Reporter: timeless, Assigned: Chris Thomas (CTho) [formerly cst@andrew.cmu.edu cst@yecc.com])

Tracking

({memory-leak})

Trunk
mozilla1.8alpha4
memory-leak
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

14 years ago
a do {} while (0) loop could be used, otherwise something will have to manage
that pointer...
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.8alpha4
Attachment #156218 - Flags: superreview?(jst)
Attachment #156218 - Flags: review?(darin)

Comment 2

14 years ago
Comment on attachment 156218 [details] [diff] [review]
patch v1

>Index: nsDocShell.cpp

>     nsDocShellEnumerator*   docShellEnum;
>     if (aDirection == ENUMERATE_FORWARDS)
>         docShellEnum = new nsDocShellForwardsEnumerator;
>     else
>         docShellEnum = new nsDocShellBackwardsEnumerator;
>     
>     if (!docShellEnum) return NS_ERROR_OUT_OF_MEMORY;
>     
>+    nsCOMPtr<nsISupports> docShellEnumPtr(docShellEnum);

you could also just change the declaration of docShellEnum to:

      nsRefPtr<nsDocShellEnumerator> docShellEnum;

nsRefPtr is just like nsCOMPtr except that it can be used with
concrete class pointers.
Attachment #156218 - Flags: superreview?(jst)
Attachment #156218 - Flags: review?(darin)
Attachment #156307 - Flags: superreview?(jst)
Attachment #156307 - Flags: review?(darin)
Comment on attachment 156307 [details] [diff] [review]
Patch v2

sr=jst
Attachment #156307 - Flags: superreview?(jst) → superreview+
(Reporter)

Updated

14 years ago
Attachment #156307 - Flags: review?(darin) → review+
Timeless checked in the patch.
Status: ASSIGNED → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED

Updated

14 years ago
Keywords: mlk
You need to log in before you can comment on or make changes to this bug.