Bug 6158 - Fix leaks in PassRefPtr
Summary: Fix leaks in PassRefPtr
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Maciej Stachowiak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-20 02:43 PST by Maciej Stachowiak
Modified: 2005-12-20 12:04 PST (History)
0 users

See Also:


Attachments
fix the problems (12.61 KB, patch)
2005-12-20 02:44 PST, Maciej Stachowiak
no flags Details | Formatted Diff | Diff
fix problem with last attachment (13.02 KB, patch)
2005-12-20 04:20 PST, Maciej Stachowiak
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Stachowiak 2005-12-20 02:43:11 PST
There's two problems with PassRefPtr that can cause memory problems:

1) The RefPtr assignment from PassRefPtr has an extra ref

2) PassRefPtr doesn't declare a copy constructor, this means the default is used and that doesn't properly 
transfer ownership.
Comment 1 Maciej Stachowiak 2005-12-20 02:44:28 PST
Created attachment 5172 [details]
fix the problems
Comment 2 Maciej Stachowiak 2005-12-20 04:20:50 PST
Created attachment 5177 [details]
fix problem with last attachment

First version had a bug and caused more leaks. This version is better.
Comment 3 Darin Adler 2005-12-20 09:11:56 PST
Comment on attachment 5177 [details]
fix problem with last attachment

I think pass should take a const RefPtr<T>& rather than a RefPtr<T> to avoid
reference count churn.

r=me
Comment 4 Maciej Stachowiak 2005-12-20 12:04:16 PST
OK, fixed it to take a const&