directshow: Validate enumerated AM_MEDIA_TYPE struct

The video info struct can be null if format is undefined

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3323>
This commit is contained in:
Seungha Yang 2022-11-04 18:32:05 +09:00 committed by GStreamer Marge Bot
parent 786b7699d1
commit bfed80a82c

View file

@ -97,7 +97,15 @@ gst_dshow_new_pin_mediatype_from_enum_mediatypes (IPin * pin, IEnumMediaTypes *e
return NULL; return NULL;
} }
/* FORMAT_None or GUID_NULL format type does hold format data */
if (pin_mediatype->mediatype->formattype == FORMAT_None ||
pin_mediatype->mediatype->formattype == GUID_NULL) {
return NULL;
}
video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat; video_info = (VIDEOINFOHEADER *) pin_mediatype->mediatype->pbFormat;
if (!video_info)
return NULL;
pin_mediatype->defaultWidth = video_info->bmiHeader.biWidth; pin_mediatype->defaultWidth = video_info->bmiHeader.biWidth;
pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight; pin_mediatype->defaultHeight = video_info->bmiHeader.biHeight;