summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Katz <[email protected]>2022-04-26 10:33:16 -0700
committerGitHub <[email protected]>2022-04-26 10:33:16 -0700
commit6f1c7c97a337a080f177f489fd50cc1810b60fe7 (patch)
tree33a82980352cf366b9c288cf8a74d2740272d90b
parent9e1a643093cac60cd333b6d69abc1e4118a12d63 (diff)
Check success of StringFromCLSID before printing string (#1) (#716)
* Check success of StringFromCLSID before printing string * initialized wchar ptr to null
-rw-r--r--avstream/samplemft0/Mft0.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/avstream/samplemft0/Mft0.cpp b/avstream/samplemft0/Mft0.cpp
index 044a4e71..e714d46f 100644
--- a/avstream/samplemft0/Mft0.cpp
+++ b/avstream/samplemft0/Mft0.cpp
@@ -298,7 +298,7 @@ STDMETHODIMP CMft0::GetInputAvailableType(
IUnknown *pUnk = NULL;
IMFAttributes *pSourceAttributes = NULL;
UINT32 uiSourceStreamId = 0;
- wchar_t *pszName;
+ wchar_t *pszName = NULL;
EnterCriticalSection(&m_critSec);
@@ -321,8 +321,7 @@ STDMETHODIMP CMft0::GetInputAvailableType(
} else if(m_stStreamType == PINNAME_IMAGE) {
wprintf(L"Stream type: PINNAME_IMAGE\n");
} else {
- StringFromCLSID(m_stStreamType, &pszName);
- if(pszName){
+ if(SUCCEEDED(StringFromCLSID(m_stStreamType, &pszName)) && pszName){
wprintf(L"Stream type: %s\n", pszName);
CoTaskMemFree(pszName);
}
@@ -349,7 +348,7 @@ STDMETHODIMP CMft0::GetOutputAvailableType(
IUnknown *pUnk = NULL;
IMFAttributes *pSourceAttributes = NULL;
UINT32 uiSourceStreamId = 0;
- wchar_t *pszName;
+ wchar_t *pszName = NULL;
EnterCriticalSection(&m_critSec);
@@ -370,8 +369,10 @@ STDMETHODIMP CMft0::GetOutputAvailableType(
} else if(m_stStreamType == PINNAME_IMAGE) {
wprintf(L"Stream type: PINNAME_IMAGE\n");
} else {
- StringFromCLSID(m_stStreamType, &pszName);
- wprintf(L"Stream type: %s\n", pszName);
+ if (SUCCEEDED(StringFromCLSID(m_stStreamType, &pszName)) && pszName) {
+ wprintf(L"Stream type: %s\n", pszName);
+ CoTaskMemFree(pszName);
+ }
}
CHK_LOG_BRK((m_stStreamType == PINNAME_VIDEO_PREVIEW || m_stStreamType == PINNAME_VIDEO_CAPTURE) ? S_OK : E_UNEXPECTED);
CHK_LOG_BRK(GenerateMFMediaTypeListFromDevice(uiSourceStreamId));