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

d3d9: Use ARRAY_SIZE in d3d9_device_GetStreamSource().

parent 6b35cd29
...@@ -3709,6 +3709,7 @@ static HRESULT WINAPI d3d9_device_GetStreamSource(IDirect3DDevice9Ex *iface, ...@@ -3709,6 +3709,7 @@ static HRESULT WINAPI d3d9_device_GetStreamSource(IDirect3DDevice9Ex *iface,
UINT stream_idx, IDirect3DVertexBuffer9 **buffer, UINT *offset, UINT *stride) UINT stream_idx, IDirect3DVertexBuffer9 **buffer, UINT *offset, UINT *stride)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_stateblock_state *state;
const struct wined3d_stream_state *stream; const struct wined3d_stream_state *stream;
struct d3d9_vertexbuffer *buffer_impl; struct d3d9_vertexbuffer *buffer_impl;
...@@ -3718,14 +3719,15 @@ static HRESULT WINAPI d3d9_device_GetStreamSource(IDirect3DDevice9Ex *iface, ...@@ -3718,14 +3719,15 @@ static HRESULT WINAPI d3d9_device_GetStreamSource(IDirect3DDevice9Ex *iface,
if (!buffer) if (!buffer)
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
if (stream_idx > WINED3D_MAX_STREAMS) if (stream_idx >= ARRAY_SIZE(state->streams))
{ {
WARN("Stream index %u out of range.\n", stream_idx); WARN("Stream index %u out of range.\n", stream_idx);
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
wined3d_mutex_lock(); wined3d_mutex_lock();
stream = &wined3d_stateblock_get_state(device->state)->streams[stream_idx]; state = wined3d_stateblock_get_state(device->state);
stream = &state->streams[stream_idx];
if (stream->buffer) if (stream->buffer)
{ {
buffer_impl = wined3d_buffer_get_parent(stream->buffer); buffer_impl = wined3d_buffer_get_parent(stream->buffer);
......
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