From b4ee86d1e7527ddccfa7a6d356e4287ac8b5976b Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 9 Feb 2024 20:27:29 +0900 Subject: [PATCH] ksdeviceprovider: Fix crash while probing device caps Ignore unexpected media type reported by driver, instead of abort Part-of: --- .../gst-plugins-bad/sys/winks/ksvideohelpers.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/winks/ksvideohelpers.c b/subprojects/gst-plugins-bad/sys/winks/ksvideohelpers.c index a5b53c15be..049a592cb8 100644 --- a/subprojects/gst-plugins-bad/sys/winks/ksvideohelpers.c +++ b/subprojects/gst-plugins-bad/sys/winks/ksvideohelpers.c @@ -531,9 +531,20 @@ ks_video_probe_filter_for_caps (HANDLE filter_handle) entry = NULL; } - if (entry != NULL) { - g_assert (entry->sample_size != 0); + /* XXX: We've been doing g_assert (entry->sample_size != 0) + * since more than 10 years ago, but it's quite questionable. + * According to MS documentation, + * SampleSize field in KSDATARANGE struct is ignored, + * and biSizeImage in KS_BITMAPINFOHEADER is required only if + * compression is used. (driver maybe set zero for raw image). + * But since we've expected the value shouldn't be zero, + * let's ignore a media type with entry->sample_size == 0 for now. + * Actually people should not use this plugin in newly written code + * anymore */ + if (entry && entry->sample_size == 0) + g_clear_pointer (&entry, ks_video_media_type_free); + if (entry != NULL) { if (src_vscc != NULL) { memcpy ((gpointer) & entry->vscc, src_vscc, sizeof (entry->vscc));