qcap: Validate the index in AMStreamConfig_GetStreamCaps().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-11-25 17:43:37 -06:00 committed by Alexandre Julliard
parent fa0ff00e57
commit d00c6af248
3 changed files with 10 additions and 20 deletions

View file

@ -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,

View file

@ -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)

View file

@ -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 =