Closed Bug 619797 Opened 10 years ago Closed 10 years ago

imgRequest::Init should manage observer more carefully

Categories

(Core :: ImageLib, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b10

People

(Reporter: timeless, Assigned: timeless)

References

(Blocks 1 open bug, )

Details

(Keywords: coverity, memory-leak)

Attachments

(1 file, 1 obsolete file)

205 nsresult imgRequest::Init(nsIURI *aURI,

243   if (NS_UNLIKELY(!gRegisteredPrefObserver)) {

this should be done after getting branch in order to avoid leaking it:
244     imgRequestPrefObserver *observer = new imgRequestPrefObserver();
245     if (observer) {
246       nsCOMPtr<nsIPrefBranch2> branch = do_GetService(NS_PREFSERVICE_CONTRACTID);
247       if (branch) {
253       }
254     }
this makes no sense:
255     else
256       delete observer;
257   }
Attached patch patch (obsolete) — Splinter Review
Assignee: nobody → timeless
Status: NEW → ASSIGNED
Attachment #498302 - Flags: review?(bobbyholley+bmo)
Attachment #498302 - Flags: approval2.0?
Attachment #498302 - Flags: review?(bobbyholley+bmo) → review?(joe)
Comment on attachment 498302 [details] [diff] [review]
patch

Drop the "if(observer)" - new is infallible.
Attachment #498302 - Flags: review?(joe)
Attachment #498302 - Flags: review+
Attachment #498302 - Flags: approval2.0?
Attachment #498302 - Flags: approval2.0+
Attached patch patchSplinter Review
Attachment #498302 - Attachment is obsolete: true
Attachment #502357 - Flags: review+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/94481eaabdaf
Keywords: checkin-needed
Target Milestone: --- → mozilla2.0b10
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.