Commit a3b36a34 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3d9: Validate the stream index in d3d9_device_SetStreamSource().

parent bd58d132
...@@ -3669,16 +3669,25 @@ static HRESULT WINAPI d3d9_device_SetStreamSource(IDirect3DDevice9Ex *iface, ...@@ -3669,16 +3669,25 @@ static HRESULT WINAPI d3d9_device_SetStreamSource(IDirect3DDevice9Ex *iface,
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct d3d9_vertexbuffer *buffer_impl = unsafe_impl_from_IDirect3DVertexBuffer9(buffer); struct d3d9_vertexbuffer *buffer_impl = unsafe_impl_from_IDirect3DVertexBuffer9(buffer);
const struct wined3d_stateblock_state *state;
struct wined3d_buffer *wined3d_buffer; struct wined3d_buffer *wined3d_buffer;
HRESULT hr; HRESULT hr;
TRACE("iface %p, stream_idx %u, buffer %p, offset %u, stride %u.\n", TRACE("iface %p, stream_idx %u, buffer %p, offset %u, stride %u.\n",
iface, stream_idx, buffer, offset, stride); iface, stream_idx, buffer, offset, stride);
if (stream_idx >= ARRAY_SIZE(state->streams))
{
WARN("Stream index %u out of range.\n", stream_idx);
return WINED3DERR_INVALIDCALL;
}
wined3d_mutex_lock(); wined3d_mutex_lock();
if (!buffer_impl) if (!buffer_impl)
{ {
const struct wined3d_stream_state *stream = &wined3d_stateblock_get_state(device->state)->streams[stream_idx]; const struct wined3d_stream_state *stream;
state = wined3d_stateblock_get_state(device->state);
stream = &state->streams[stream_idx];
wined3d_buffer = stream->buffer; wined3d_buffer = stream->buffer;
offset = stream->offset; offset = stream->offset;
stride = stream->stride; stride = stream->stride;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment