Bug 65790 - [QT] Possible Leaks WKRetainPtr<> should Adopt allocated Copy
Summary: [QT] Possible Leaks WKRetainPtr<> should Adopt allocated Copy
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-05 14:18 PDT by Joseph Pecoraro
Modified: 2011-08-07 12:42 PDT (History)
3 users (show)

See Also:


Attachments
[PATCH] Untested Proposed Fix (1.63 KB, patch)
2011-08-05 14:25 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2011-08-05 14:18:48 PDT
shell> cd Source/
shell> a 'Retain.*?=.*?Copy'

    WebKit2/UIProcess/API/qt/qweberror.cpp
    61:    WKRetainPtr<WKStringRef> errorDomainPtr = adoptWK(WKErrorCopyDomain(d->error.get()));
    80:    WKRetainPtr<WKURLRef> failingURL = adoptWK(WKErrorCopyFailingURL(d->error.get()));
    
    WebKit2/UIProcess/qt/qwkhistory.cpp
    76:    WKRetainPtr<WKStringRef> title = WKBackForwardListItemCopyTitle(d->m_backForwardListItem.get());
    84:    WKRetainPtr<WKURLRef> url = WKBackForwardListItemCopyURL(d->m_backForwardListItem.get());

These look like possible leaks. Since WKRetainPtr::operator= does a WKRetain and typically a WK*Copy*()
will return a +1 allocation. I think the correct behavior here would be AdoptWK like:

    WebKit2/UIProcess/qt/qwkpreferences.cpp
    93:        WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyStandardFontFamily(d->ref));
Comment 1 Joseph Pecoraro 2011-08-05 14:20:09 PDT
I should clarify.

>     WebKit2/UIProcess/API/qt/qweberror.cpp
>     61:    WKRetainPtr<WKStringRef> errorDomainPtr = adoptWK(WKErrorCopyDomain(d->error.get()));
>     80:    WKRetainPtr<WKURLRef> failingURL = adoptWK(WKErrorCopyFailingURL(d->error.get()));

These look good because of the adoptWK(...).

>     WebKit2/UIProcess/qt/qwkhistory.cpp
>     76:    WKRetainPtr<WKStringRef> title = WKBackForwardListItemCopyTitle(d->m_backForwardListItem.get());
>     84:    WKRetainPtr<WKURLRef> url = WKBackForwardListItemCopyURL(d->m_backForwardListItem.get());

These however don't look so good.
Comment 2 Joseph Pecoraro 2011-08-05 14:25:16 PDT
Created attachment 103114 [details]
[PATCH] Untested Proposed Fix

I haven't tested this patch so I really suggest a WebKit2 / Qt developer take a look at this.
I did not do a Qt build to test this, I just inspected the source.
Comment 3 WebKit Review Bot 2011-08-07 12:42:36 PDT
Comment on attachment 103114 [details]
[PATCH] Untested Proposed Fix

Clearing flags on attachment: 103114

Committed r92574: <http://trac.webkit.org/changeset/92574>
Comment 4 WebKit Review Bot 2011-08-07 12:42:40 PDT
All reviewed patches have been landed.  Closing bug.