Closed Bug 1160428 Opened 6 years ago Closed 6 years ago

Memory leak in DOMCameraControlListener::OnTakePictureComplete::Callback

Categories

(Firefox OS Graveyard :: Gaia::Camera, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(firefox40 fixed)

RESOLVED FIXED
2.2 S12 (15may)
Tracking Status
firefox40 --- fixed

People

(Reporter: mccr8, Assigned: royang51)

References

Details

(Keywords: coverity, memory-leak, Whiteboard: [CID 1296250][MemShrink])

Attachments

(1 file, 1 obsolete file)

Coverity identified this memory leak.  mData is allocated in the ctor of Callback, but never freed.
(In reply to Andrew McCreight (awayish through 5/5) [:mccr8] from comment #0)
> Coverity identified this memory leak.  mData is allocated in the ctor of
> Callback, but never freed.

It looks like it would only be leaked in the case the |RunCallback| is not hit. If you dig far enough you can see the memory is taken by a |DataOwner| [1] if |RunCallback| is called.

Probably the simplest solution is to free in a dtor and null out the pointer in RunCallback when transferring ownership.

[1] https://hg.mozilla.org/mozilla-central/annotate/7723b15ea695/dom/base/File.h#l530
Assignee: nobody → royang51
Attached patch bug1160428.patch, V1 (obsolete) — Splinter Review
Attachment #8600593 - Flags: review?(aosmond)
Comment on attachment 8600593 [details] [diff] [review]
bug1160428.patch, V1

Review of attachment 8600593 [details] [diff] [review]:
-----------------------------------------------------------------

Conditional r+. When you reattach, append "[carries r=aosmond]" to the description and set the review+ flag.

::: dom/camera/DOMCameraControlListener.cpp
@@ +367,5 @@
>        aDOMCameraControl->OnTakePictureComplete(picture);
> +      mData = NULL;
> +    }
> +
> +    ~Callback()

The destructor should be protected and virtual.
Attachment #8600593 - Flags: review?(aosmond) → review+
Attachment #8600593 - Attachment is obsolete: true
Attachment #8600724 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/995db217fd1b
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.2 S12 (15may)
You need to log in before you can comment on or make changes to this bug.