Zebediah Figura : qcap: Validate the index in AMStreamConfig_GetStreamCaps().

Alexandre Julliard julliard at winehq.org
Thu Nov 26 16:30:59 CST 2020


Module: wine
Branch: master
Commit: d00c6af248a47fe0ed9b2bc7cbf399152bfe73bd
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d00c6af248a47fe0ed9b2bc7cbf399152bfe73bd

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed Nov 25 17:43:37 2020 -0600

qcap: Validate the index in AMStreamConfig_GetStreamCaps().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/qcap/qcap_private.h |  2 +-
 dlls/qcap/v4l.c          |  6 +-----
 dlls/qcap/vfwcapture.c   | 22 ++++++++--------------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/dlls/qcap/qcap_private.h b/dlls/qcap/qcap_private.h
index 834994d8cac..e2f032d2079 100644
--- a/dlls/qcap/qcap_private.h
+++ b/dlls/qcap/qcap_private.h
@@ -48,7 +48,7 @@ struct video_capture_funcs
     HRESULT (*set_format)(struct video_capture_device *device, const AM_MEDIA_TYPE *mt);
     HRESULT (*get_format)(struct video_capture_device *device, AM_MEDIA_TYPE *mt);
     HRESULT (*get_media_type)(struct video_capture_device *device, unsigned int index, AM_MEDIA_TYPE *mt);
-    HRESULT (*get_caps)(struct video_capture_device *device, LONG index, AM_MEDIA_TYPE *mt,
+    void (*get_caps)(struct video_capture_device *device, LONG index, AM_MEDIA_TYPE *mt,
             VIDEOINFOHEADER *format, VIDEO_STREAM_CONFIG_CAPS *caps);
     LONG (*get_caps_count)(struct video_capture_device *device);
     HRESULT (*get_prop_range)(struct video_capture_device *device, VideoProcAmpProperty property,
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c
index db838f1efe4..e0a6593a024 100644
--- a/dlls/qcap/v4l.c
+++ b/dlls/qcap/v4l.c
@@ -373,16 +373,12 @@ static void fill_caps(__u32 pixelformat, __u32 width, __u32 height,
     caps->pixelformat = pixelformat;
 }
 
-static HRESULT v4l_device_get_caps(struct video_capture_device *device, LONG index,
+static void v4l_device_get_caps(struct video_capture_device *device, LONG index,
         AM_MEDIA_TYPE *type, VIDEOINFOHEADER *format, VIDEO_STREAM_CONFIG_CAPS *vscc)
 {
-    if (index >= device->caps_count)
-        return S_FALSE;
-
     *vscc = device->caps[index].config;
     *type = device->caps[index].media_type;
     *format = device->caps[index].video_info;
-    return S_OK;
 }
 
 static LONG v4l_device_get_caps_count(struct video_capture_device *device)
diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c
index 62d692226c5..09cb7e36cc2 100644
--- a/dlls/qcap/vfwcapture.c
+++ b/dlls/qcap/vfwcapture.c
@@ -377,10 +377,12 @@ static HRESULT WINAPI AMStreamConfig_GetStreamCaps(IAMStreamConfig *iface,
     struct vfw_capture *filter = impl_from_IAMStreamConfig(iface);
     VIDEOINFOHEADER *format;
     AM_MEDIA_TYPE *mt;
-    HRESULT hr;
 
     TRACE("filter %p, index %d, pmt %p, vscc %p.\n", filter, index, pmt, vscc);
 
+    if (index > capture_funcs->get_caps_count(filter->device))
+        return S_FALSE;
+
     if (!(mt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
         return E_OUTOFMEMORY;
 
@@ -390,19 +392,11 @@ static HRESULT WINAPI AMStreamConfig_GetStreamCaps(IAMStreamConfig *iface,
         return E_OUTOFMEMORY;
     }
 
-    if ((hr = capture_funcs->get_caps(filter->device, index, mt,
-            format, (VIDEO_STREAM_CONFIG_CAPS *)vscc)) == S_OK)
-    {
-        mt->cbFormat = sizeof(VIDEOINFOHEADER);
-        mt->pbFormat = (BYTE *)format;
-        *pmt = mt;
-    }
-    else
-    {
-        CoTaskMemFree(format);
-        CoTaskMemFree(mt);
-    }
-    return hr;
+    capture_funcs->get_caps(filter->device, index, mt, format, (VIDEO_STREAM_CONFIG_CAPS *)vscc);
+    mt->cbFormat = sizeof(VIDEOINFOHEADER);
+    mt->pbFormat = (BYTE *)format;
+    *pmt = mt;
+    return S_OK;
 }
 
 static const IAMStreamConfigVtbl IAMStreamConfig_VTable =




More information about the wine-cvs mailing list