WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
25294
All WebKit/win classes should return COMPtrs from their static constructor members
https://bugs.webkit.org/show_bug.cgi?id=25294
Summary
All WebKit/win classes should return COMPtrs from their static constructor me...
Adam Roben (:aroben)
Reported
2009-04-20 07:42:57 PDT
All classes in WebKit/win should return COMPtrs from their static constructor members (e.g., createInstance()). This will help prevent memory leaks/crashes caused by incorrect ref-count management.
Attachments
patch for MemoryStream
(8.04 KB, patch)
2009-04-20 08:05 PDT
,
Adam Roben (:aroben)
no flags
Details
Formatted Diff
Diff
Make CFDictionaryPropertyBag::createInstance return a COMPtr
(17.85 KB, patch)
2009-11-05 10:09 PST
,
Adam Roben (:aroben)
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Adam Roben (:aroben)
Comment 1
2009-04-20 07:43:11 PDT
<
rdar://problem/6803127
>
Adam Roben (:aroben)
Comment 2
2009-04-20 08:05:57 PDT
Created
attachment 29616
[details]
patch for MemoryStream
Darin Adler
Comment 3
2009-04-20 09:19:39 PDT
Comment on
attachment 29616
[details]
patch for MemoryStream
> HRESULT STDMETHODCALLTYPE MemoryStream::Clone( > /* [out] */ IStream** ppstm) > { > - *ppstm = MemoryStream::createInstance(m_buffer); > + *ppstm = MemoryStream::createInstance(m_buffer).releaseRef(); > + // FIXME: MSDN says we should be returning STG_E_INSUFFICIENT_MEMORY instead of E_OUTOFMEMORY here. > return (*ppstm) ? S_OK : E_OUTOFMEMORY;
Why not copyRefTo here?
> - COMPtr<IStream> stream(AdoptCOM, MemoryStream::createInstance(buffer.release())); > + COMPtr<MemoryStream> stream = MemoryStream::createInstance(buffer.release()); > m_view->didReceiveData(stream.get());
Would this read better without the local variable?
> - COMPtr<MemoryStream> result(AdoptCOM, MemoryStream::createInstance(SharedBuffer::wrapCFData(historyData.get()))); > + COMPtr<MemoryStream> result = MemoryStream::createInstance(SharedBuffer::wrapCFData(historyData.get())); > return result.copyRefTo(stream);
Would this read better without the local variable? r=me
Adam Roben (:aroben)
Comment 4
2009-04-20 09:23:24 PDT
(In reply to
comment #3
)
> (From update of
attachment 29616
[details]
[review]) > > HRESULT STDMETHODCALLTYPE MemoryStream::Clone( > > /* [out] */ IStream** ppstm) > > { > > - *ppstm = MemoryStream::createInstance(m_buffer); > > + *ppstm = MemoryStream::createInstance(m_buffer).releaseRef(); > > + // FIXME: MSDN says we should be returning STG_E_INSUFFICIENT_MEMORY instead of E_OUTOFMEMORY here. > > return (*ppstm) ? S_OK : E_OUTOFMEMORY; > > Why not copyRefTo here?
I originally thought that copyRefTo's behavior was incompatible with the existing behavior of this function. But now I see that it isn't. I will change to use copyRefTo.
> > - COMPtr<IStream> stream(AdoptCOM, MemoryStream::createInstance(buffer.release())); > > + COMPtr<MemoryStream> stream = MemoryStream::createInstance(buffer.release()); > > m_view->didReceiveData(stream.get()); > > Would this read better without the local variable?
Probably. I'll remove the variable.
> > - COMPtr<MemoryStream> result(AdoptCOM, MemoryStream::createInstance(SharedBuffer::wrapCFData(historyData.get()))); > > + COMPtr<MemoryStream> result = MemoryStream::createInstance(SharedBuffer::wrapCFData(historyData.get())); > > return result.copyRefTo(stream); > > Would this read better without the local variable?
Maybe. I'll remove the variable and see how it looks. Thanks for the review!
Adam Roben (:aroben)
Comment 5
2009-04-20 20:43:09 PDT
Comment on
attachment 29616
[details]
patch for MemoryStream Landed as
r42692
Adam Roben (:aroben)
Comment 6
2009-11-05 10:09:46 PST
Created
attachment 42574
[details]
Make CFDictionaryPropertyBag::createInstance return a COMPtr
Adam Roben (:aroben)
Comment 7
2009-11-05 10:17:48 PST
Comment on
attachment 42574
[details]
Make CFDictionaryPropertyBag::createInstance return a COMPtr Landed as
r50567
<
http://trac.webkit.org/changeset/50567
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug