From 3cc9e40c3bae7571574565a719cded877ccef29b Mon Sep 17 00:00:00 2001 From: Ivan Leo Puoti Date: Wed, 21 Dec 2005 21:11:54 +0100 Subject: [PATCH] ddraw: Fix DirectDrawSurface::QueryInterface crash. --- dlls/ddraw/surface_main.c | 3 +++ dlls/ddraw/tests/dsurface.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/dlls/ddraw/surface_main.c b/dlls/ddraw/surface_main.c index fd10394f055..ba113590fa5 100644 --- a/dlls/ddraw/surface_main.c +++ b/dlls/ddraw/surface_main.c @@ -160,6 +160,9 @@ Main_DirectDrawSurface_QueryInterface(LPDIRECTDRAWSURFACE7 iface, REFIID riid, *ppObj = NULL; + if(!riid) + return DDERR_INVALIDPARAMS; + if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDirectDrawSurface7, riid) || IsEqualGUID(&IID_IDirectDrawSurface4, riid)) diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c index 10faf02e05c..e1e0c933091 100644 --- a/dlls/ddraw/tests/dsurface.c +++ b/dlls/ddraw/tests/dsurface.c @@ -3,6 +3,7 @@ * * Copyright (C) 2005 Antoine Chavasse (a.chavasse@gmail.com) * Copyright (C) 2005 Christian Costa + * Copyright 2005 Ivan Leo Puoti * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -220,11 +221,38 @@ static void SrcColorKey32BlitTest(void) IDirectDrawSurface_Release(lpDst); } +static void QueryInterface(void) +{ + LPDIRECTDRAWSURFACE dsurface; + DDSURFACEDESC surface; + LPVOID object; + HRESULT ret; + + /* Create a surface */ + ZeroMemory(&surface, sizeof(surface)); + surface.dwSize = sizeof(surface); + surface.dwFlags = DDSD_WIDTH | DDSD_HEIGHT; + surface.dwHeight = 10; + surface.dwWidth = 10; + ret = IDirectDraw_CreateSurface(lpDD, &surface, &dsurface, NULL); + if(ret != DD_OK) + { + ok(FALSE, "IDirectDraw::CreateSurface failed with error %lx\n", ret); + return; + } + + /* Call IUnkown::QueryInterface */ + ret = IDirectDrawSurface_QueryInterface(dsurface, 0, &object); + ok(ret == DDERR_INVALIDPARAMS, "IDirectDrawSurface::QueryInterface returned %lx\n", ret); + + IDirectDrawSurface_Release(dsurface); +} START_TEST(dsurface) { CreateDirectDraw(); MipMapCreationTest(); SrcColorKey32BlitTest(); + QueryInterface(); ReleaseDirectDraw(); } -- 2.11.4.GIT