Zhiyi Zhang : winegstreamer: Always check the return value from mf_media_type_from_wg_format().

Alexandre Julliard julliard at winehq.org
Thu Aug 11 15:27:34 CDT 2022


Module: wine
Branch: master
Commit: 6f8990b4318b25709cd90f6e10e8f3fdaa89c4c4
URL:    https://gitlab.winehq.org/wine/wine/-/commit/6f8990b4318b25709cd90f6e10e8f3fdaa89c4c4

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Mon Aug  1 17:19:48 2022 +0800

winegstreamer: Always check the return value from mf_media_type_from_wg_format().

mf_media_type_from_wg_format() may return NULL.

Fix Airborne Kingdom crash at start because WG_AUDIO_FORMAT_UNKNOWN is passed to
mf_media_type_from_wg_format().

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>

---

 dlls/winegstreamer/media_source.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index f07b83f413e..43beb71838a 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -879,6 +879,12 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
         IMFMediaType *base_type = mf_media_type_from_wg_format(&format);
         GUID base_subtype;
 
+        if (!base_type)
+        {
+            hr = MF_E_INVALIDMEDIATYPE;
+            goto done;
+        }
+
         IMFMediaType_GetGUID(base_type, &MF_MT_SUBTYPE, &base_subtype);
 
         stream_types[0] = base_type;
@@ -911,8 +917,8 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
             WG_AUDIO_FORMAT_F32LE,
         };
 
-        stream_types[0] = mf_media_type_from_wg_format(&format);
-        type_count = 1;
+        if ((stream_types[0] = mf_media_type_from_wg_format(&format)))
+            type_count = 1;
 
         for (i = 0; i < ARRAY_SIZE(audio_types); i++)
         {
@@ -921,7 +927,8 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
                 continue;
             new_format = format;
             new_format.u.audio.format = audio_types[i];
-            stream_types[type_count++] = mf_media_type_from_wg_format(&new_format);
+            if ((stream_types[type_count] = mf_media_type_from_wg_format(&new_format)))
+                type_count++;
         }
     }
     else




More information about the wine-cvs mailing list