ddraw: Validate the surface pitch for user memory surfaces in ddraw_surface_init().

This commit is contained in:
Henri Verbeet 2014-03-04 10:21:37 +01:00 committed by Alexandre Julliard
parent 10db40cecc
commit 9c138d772c
1 changed files with 6 additions and 0 deletions

View File

@ -6067,6 +6067,12 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
if (desc->dwFlags & DDSD_LPSURFACE) if (desc->dwFlags & DDSD_LPSURFACE)
{ {
if (desc->u1.lPitch < wined3d_surface_get_pitch(wined3d_surface) || desc->u1.lPitch & 3)
{
WARN("Invalid pitch %u specified.\n", desc->u1.lPitch);
return DDERR_INVALIDPARAMS;
}
if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width, if (FAILED(hr = wined3d_surface_update_desc(wined3d_surface, wined3d_desc.width,
wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0, wined3d_desc.height, wined3d_desc.format, WINED3D_MULTISAMPLE_NONE, 0,
desc->lpSurface, desc->u1.lPitch))) desc->lpSurface, desc->u1.lPitch)))