[vlc-commits] ActiveX: fixed memory leak on multiple DllGetClassObject call
rsatom@gmail.com
git at videolan.org
Fri Oct 5 17:36:48 CEST 2012
npapi-vlc | branch: master | rsatom at gmail.com <rsatom at gmail.com> | Sat Sep 29 11:43:28 2012 +0000| [501e348c20a80281efb2ded023e8873eb4aea151] | committer: Jean-Baptiste Kempf
ActiveX: fixed memory leak on multiple DllGetClassObject call
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=501e348c20a80281efb2ded023e8873eb4aea151
---
activex/plugin.cpp | 10 ++++++----
activex/plugin.h | 1 +
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/activex/plugin.cpp b/activex/plugin.cpp
index ca3932d..8f9896d 100644
--- a/activex/plugin.cpp
+++ b/activex/plugin.cpp
@@ -94,6 +94,7 @@ static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wPar
VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID rclsid) :
_p_class_ref(p_class_ref),
+ _class_ref(0),
_hinstance(hInstance),
_classid(rclsid),
_inplace_picture(NULL)
@@ -166,18 +167,19 @@ STDMETHODIMP VLCPluginClass::QueryInterface(REFIID riid, void **ppv)
STDMETHODIMP_(ULONG) VLCPluginClass::AddRef(void)
{
- return InterlockedIncrement(_p_class_ref);
+ InterlockedIncrement(_p_class_ref);
+ return ++_class_ref;
};
STDMETHODIMP_(ULONG) VLCPluginClass::Release(void)
{
- ULONG refcount = InterlockedDecrement(_p_class_ref);
- if( 0 == refcount )
+ InterlockedDecrement(_p_class_ref);
+ if( 0 == (--_class_ref) )
{
delete this;
return 0;
}
- return refcount;
+ return _class_ref;
};
STDMETHODIMP VLCPluginClass::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv)
diff --git a/activex/plugin.h b/activex/plugin.h
index 06fb5c0..7569c65 100644
--- a/activex/plugin.h
+++ b/activex/plugin.h
@@ -70,6 +70,7 @@ protected:
private:
LPLONG _p_class_ref;
+ ULONG _class_ref;
HINSTANCE _hinstance;
CLSID _classid;
ATOM _inplace_wndclass_atom;
More information about the vlc-commits
mailing list