Fix BSTR leaks in wxAMMediaBackend and wxWMP10MediaBackend.

This commit is contained in:
PB
2017-07-01 13:07:59 +02:00
parent ca3f919da9
commit 6725a0a1b8
2 changed files with 20 additions and 20 deletions

View File

@@ -1127,7 +1127,7 @@ bool wxAMMediaBackend::Load(const wxURI& location, const wxURI& proxy)
if(pPlay) if(pPlay)
{ {
pPlay->put_UseHTTPProxy(VARIANT_TRUE); pPlay->put_UseHTTPProxy(VARIANT_TRUE);
pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()).Detach()); pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()));
pPlay->put_HTTPProxyPort(wxAtoi(proxy.GetPort())); pPlay->put_HTTPProxyPort(wxAtoi(proxy.GetPort()));
pPlay->Release(); pPlay->Release();
} }
@@ -1150,9 +1150,9 @@ bool wxAMMediaBackend::DoLoad(const wxString& location)
// the docs say its async and put_FileName is not - // the docs say its async and put_FileName is not -
// but in practice they both seem to be async anyway // but in practice they both seem to be async anyway
if(GetMP()) if(GetMP())
hr = GetMP()->Open( wxBasicString(location).Detach() ); hr = GetMP()->Open( wxBasicString(location) );
else else
hr = GetAM()->put_FileName( wxBasicString(location).Detach() ); hr = GetAM()->put_FileName( wxBasicString(location) );
if(FAILED(hr)) if(FAILED(hr))
{ {

View File

@@ -905,21 +905,21 @@ bool wxWMP10MediaBackend::Load(const wxURI& location,
{ {
long lOldSetting; long lOldSetting;
if( pWMPNetwork->getProxySettings( if( pWMPNetwork->getProxySettings(
wxBasicString(location.GetScheme()).Get(), &lOldSetting wxBasicString(location.GetScheme()), &lOldSetting
) == 0 && ) == 0 &&
pWMPNetwork->setProxySettings( pWMPNetwork->setProxySettings(
wxBasicString(location.GetScheme()).Detach(), // protocol wxBasicString(location.GetScheme()), // protocol
2) == 0) // 2 == manually specify 2) == 0) // 2 == manually specify
{ {
BSTR bsOldName = NULL; wxBasicString bsOldName;
long lOldPort = 0; long lOldPort = 0;
pWMPNetwork->getProxyName( pWMPNetwork->getProxyName(
wxBasicString(location.GetScheme()).Detach(), wxBasicString(location.GetScheme()),
&bsOldName); bsOldName.ByRef());
pWMPNetwork->getProxyPort( pWMPNetwork->getProxyPort(
wxBasicString(location.GetScheme()).Detach(), wxBasicString(location.GetScheme()),
&lOldPort); &lOldPort);
long lPort; long lPort;
@@ -936,11 +936,11 @@ bool wxWMP10MediaBackend::Load(const wxURI& location,
} }
if( pWMPNetwork->setProxyName( if( pWMPNetwork->setProxyName(
wxBasicString(location.GetScheme()).Detach(), // proto wxBasicString(location.GetScheme()), // proto
wxBasicString(server).Get() ) == 0 && wxBasicString(server) ) == 0 &&
pWMPNetwork->setProxyPort( pWMPNetwork->setProxyPort(
wxBasicString(location.GetScheme()).Detach(), // proto wxBasicString(location.GetScheme()), // proto
lPort lPort
) == 0 ) == 0
) )
@@ -948,16 +948,16 @@ bool wxWMP10MediaBackend::Load(const wxURI& location,
bOK = DoLoad(location.BuildURI()); bOK = DoLoad(location.BuildURI());
pWMPNetwork->setProxySettings( pWMPNetwork->setProxySettings(
wxBasicString(location.GetScheme()).Detach(), // protocol wxBasicString(location.GetScheme()), // protocol
lOldSetting); lOldSetting);
if(bsOldName) if(bsOldName)
pWMPNetwork->setProxyName( pWMPNetwork->setProxyName(
wxBasicString(location.GetScheme()).Detach(), // protocol wxBasicString(location.GetScheme()), // protocol
bsOldName); bsOldName);
if(lOldPort) if(lOldPort)
pWMPNetwork->setProxyPort( pWMPNetwork->setProxyPort(
wxBasicString(location.GetScheme()).Detach(), // protocol wxBasicString(location.GetScheme()), // protocol
lOldPort); lOldPort);
pWMPNetwork->Release(); pWMPNetwork->Release();
@@ -997,7 +997,7 @@ bool wxWMP10MediaBackend::DoLoad(const wxString& location)
{ {
IWMPMedia* pWMPMedia; IWMPMedia* pWMPMedia;
if( (hr = pWMPCore3->newMedia(wxBasicString(location).Get(), if( (hr = pWMPCore3->newMedia(wxBasicString(location),
&pWMPMedia)) == 0) &pWMPMedia)) == 0)
{ {
// this (get_duration) will actually FAIL, but it will work. // this (get_duration) will actually FAIL, but it will work.
@@ -1012,7 +1012,7 @@ bool wxWMP10MediaBackend::DoLoad(const wxString& location)
#endif #endif
{ {
// just load it the "normal" way // just load it the "normal" way
hr = m_pWMPPlayer->put_URL( wxBasicString(location).Detach() ); hr = m_pWMPPlayer->put_URL( wxBasicString(location) );
} }
if(FAILED(hr)) if(FAILED(hr))
@@ -1061,12 +1061,12 @@ bool wxWMP10MediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
if(!flags) if(!flags)
{ {
m_pWMPPlayer->put_enabled(VARIANT_FALSE); m_pWMPPlayer->put_enabled(VARIANT_FALSE);
m_pWMPPlayer->put_uiMode(wxBasicString(wxT("none")).Detach()); m_pWMPPlayer->put_uiMode(wxBasicString(wxT("none")));
} }
else else
{ {
// TODO: use "custom"? (note that CE only supports none/full) // TODO: use "custom"? (note that CE only supports none/full)
m_pWMPPlayer->put_uiMode(wxBasicString(wxT("full")).Detach()); m_pWMPPlayer->put_uiMode(wxBasicString(wxT("full")));
m_pWMPPlayer->put_enabled(VARIANT_TRUE); m_pWMPPlayer->put_enabled(VARIANT_TRUE);
} }
@@ -1358,7 +1358,7 @@ wxLongLong wxWMP10MediaBackend::GetDownloadTotal()
if(m_pWMPPlayer->get_currentMedia(&pWMPMedia) == 0) if(m_pWMPPlayer->get_currentMedia(&pWMPMedia) == 0)
{ {
BSTR bsOut; BSTR bsOut;
pWMPMedia->getItemInfo(wxBasicString(wxT("FileSize")).Detach(), pWMPMedia->getItemInfo(wxBasicString(wxT("FileSize")),
&bsOut); &bsOut);
wxString sFileSize = wxConvertStringFromOle(bsOut); wxString sFileSize = wxConvertStringFromOle(bsOut);