summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVal Doroshchuk <valentyn.doroshchuk@qt.io>2020-04-06 14:14:08 +0200
committerVal Doroshchuk <valentyn.doroshchuk@qt.io>2020-04-06 14:31:43 +0200
commitc39f90e01e51c9fbc8074993a38e7f9b16338dbb (patch)
tree6407d87875c23ac8dfb35212119a7cfe31982ee0 /src/plugins
parent2a888bc3fb72069e735faad42e8325f60a5d7412 (diff)
WMF: Fix memory leak in MFPlayerSession::getStreamType
Receives a pointer to the IMFMediaTypeHandler interface. The caller must release the interface. Fixes: QTBUG-80037 Change-Id: I69682028a5deea256a79d5d067afe2e60e49c8c5 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/wmf/player/mfplayersession.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/plugins/wmf/player/mfplayersession.cpp b/src/plugins/wmf/player/mfplayersession.cpp
index 24bfda833..9761fd993 100644
--- a/src/plugins/wmf/player/mfplayersession.cpp
+++ b/src/plugins/wmf/player/mfplayersession.cpp
@@ -277,10 +277,13 @@ MFPlayerSession::MediaType MFPlayerSession::getStreamType(IMFStreamDescriptor *s
if (!stream)
return Unknown;
- IMFMediaTypeHandler *typeHandler = NULL;
- if (SUCCEEDED(stream->GetMediaTypeHandler(&typeHandler))) {
+ struct SafeRelease {
+ IMFMediaTypeHandler *ptr = nullptr;
+ ~SafeRelease() { if (ptr) ptr->Release(); }
+ } typeHandler;
+ if (SUCCEEDED(stream->GetMediaTypeHandler(&typeHandler.ptr))) {
GUID guidMajorType;
- if (SUCCEEDED(typeHandler->GetMajorType(&guidMajorType))) {
+ if (SUCCEEDED(typeHandler.ptr->GetMajorType(&guidMajorType))) {
if (guidMajorType == MFMediaType_Audio)
return Audio;
else if (guidMajorType == MFMediaType_Video)
@@ -288,9 +291,6 @@ MFPlayerSession::MediaType MFPlayerSession::getStreamType(IMFStreamDescriptor *s
}
}
- if (typeHandler)
- typeHandler->Release();
-
return Unknown;
}