Zebediah Figura : winegstreamer: Use a static buffer to enumerate stream types in media_stream_init_desc().
Alexandre Julliard
julliard at winehq.org
Mon May 17 15:45:29 CDT 2021
Module: wine
Branch: master
Commit: cf02b0bdfafddff74cfbaca88ba70c6bd59ca0b0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cf02b0bdfafddff74cfbaca88ba70c6bd59ca0b0
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Sun May 16 22:35:30 2021 -0500
winegstreamer: Use a static buffer to enumerate stream types in media_stream_init_desc().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winegstreamer/media_source.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index 7f308973270..8a87992d450 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -757,8 +757,7 @@ fail:
static HRESULT media_stream_init_desc(struct media_stream *stream)
{
IMFMediaTypeHandler *type_handler = NULL;
- IMFMediaType **stream_types = NULL;
- IMFMediaType *stream_type = NULL;
+ IMFMediaType *stream_types[6];
struct wg_format format;
DWORD type_count = 0;
unsigned int i;
@@ -784,8 +783,6 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
IMFMediaType_GetGUID(base_type, &MF_MT_SUBTYPE, &base_subtype);
- stream_types = malloc(sizeof(IMFMediaType *) * (ARRAY_SIZE(video_types) + 1));
-
stream_types[0] = base_type;
type_count = 1;
@@ -816,8 +813,6 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
WG_AUDIO_FORMAT_F32LE,
};
- stream_types = malloc( sizeof(IMFMediaType *) * (ARRAY_SIZE(audio_types) + 1) );
-
stream_types[0] = mf_media_type_from_wg_format(&format);
type_count = 1;
@@ -833,14 +828,12 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
}
else
{
- stream_type = mf_media_type_from_wg_format(&format);
- if (stream_type)
- {
- stream_types = &stream_type;
+ if ((stream_types[0] = mf_media_type_from_wg_format(&format)))
type_count = 1;
- }
}
+ assert(type_count < ARRAY_SIZE(stream_types));
+
if (!type_count)
{
ERR("Failed to establish an IMFMediaType from any of the possible stream caps!\n");
@@ -861,8 +854,6 @@ done:
IMFMediaTypeHandler_Release(type_handler);
for (i = 0; i < type_count; i++)
IMFMediaType_Release(stream_types[i]);
- if (stream_types != &stream_type)
- free(stream_types);
return hr;
}
More information about the wine-cvs
mailing list