Closed Bug 399022 Opened 17 years ago Closed 17 years ago

Leak-prone code in nsCertTree

Categories

(Core :: Security: PSM, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bzbarsky, Assigned: KaiE)

References

Details

(Keywords: memory-leak, regression)

Attachments

(1 file, 1 obsolete file)

See bug 327181 comment 134 and bug 327181 comment 135.

I'm not quite sure how this code got review, and more importantly how it got sr.  Then again, as far as I can see it in fact did not get sr.
Flags: blocking1.9?
Keywords: mlk, regression
Copying over the comments:

> So is there a reason the nsCertTree code doesn't use alread_AddRefed<> for the
> addrefed pointers it returns?  Then you wouldn't need to sprinkle
> getter_AddRefs all over where it's used....

> I'm also a little confused as to why we're manually addreffing/releasing stuff
> before putting it in mDispInfo.
Attached patch Patch v1 (obsolete) — Splinter Review
(In reply to comment #1)
> So is there a reason the nsCertTree code doesn't use alread_AddRefed<> for the
> addrefed pointers it returns?  Then you wouldn't need to sprinkle
> getter_AddRefs all over where it's used....


The reason is, I didn't think of it :-)
Thanks for your proposal.
I guess you're referring to the two private functions, and I'll change them.

Regarding the interface functions, IIUC we can't use already_AddRefed.


> I'm also a little confused as to why we're manually addreffing/releasing stuff
> before putting it in mDispInfo.

Earlier versions of the patch used an array of raw pointers, I converted it to an array of nsRefPtr late in the game. I agree when using nsRefPtr the manual addref/release is no longer required.
Attachment #284028 - Flags: review?(bzbarsky)
Comment on attachment 284028 [details] [diff] [review]
Patch v1

r=bzbarsky.  Thanks for the quick fix!
Attachment #284028 - Flags: review?(bzbarsky) → review+
Attachment #284028 - Flags: superreview?(rrelyea)
Attached patch Patch v2Splinter Review
Sorry, the previous patch didn't compile.
I had to add one more change:

@@ -868,7 +864,7 @@ NS_IMETHODIMP
 nsCertTree::GetCert(PRUint32 aIndex, nsIX509Cert **_cert)
 {
   NS_ENSURE_ARG(_cert);
-  *_cert = GetCertAtIndex(aIndex);
+  *_cert = GetCertAtIndex(aIndex).get();
   return NS_OK;
 }


This should be ok.
The get() function doesn't do anything, it just returns the raw pointer (which already has its reference counter set).
Attachment #284028 - Attachment is obsolete: true
Attachment #284045 - Flags: superreview?(rrelyea)
Attachment #284045 - Flags: review+
Attachment #284028 - Flags: superreview?(rrelyea)
I'm not sure I'm the best person to sr code based on the mozilla reference model.

Comment on attachment 284045 [details] [diff] [review]
Patch v2

Boris, do you think we'll need another review?
As this patch is really about addressing your review comments from bug 327181, I'd say it's not necessary.
Attachment #284045 - Flags: superreview?(rrelyea)
I don't know what the current review regime in PSM is.  If only one review is needed, I think we'refine.
Comment on attachment 284045 [details] [diff] [review]
Patch v2

(In reply to comment #7)
> I don't know what the current review regime in PSM is.  If only one review is
> needed, I think we'refine.

If a module-owner/peer created the patch, review from the module-owner/peer is sufficient.

As this is a correctness fix, not changing any PSM logic, I think your review was really a superreview and is sufficient for check in.
Attachment #284045 - Flags: approval1.9?
Attachment #284045 - Flags: approval1.9? → approval1.9+
checked in, marking fixed.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Reopening bug. All patches that got checked in to trunk yesterday are being backed out, because it's unclear which patch has caused a performance regression.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
checked in again, marking fixed.
Status: REOPENED → RESOLVED
Closed: 17 years ago17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: