Ivan Leo Puoti : ddraw: Fix DirectDrawSurface::QueryInterface crash.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Dec 21 14:26:11 CST 2005
Module: wine
Branch: refs/heads/master
Commit: 3cc9e40c3bae7571574565a719cded877ccef29b
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=3cc9e40c3bae7571574565a719cded877ccef29b
Author: Ivan Leo Puoti <ivanleo at gmail.com>
Date: Wed Dec 21 21:11:54 2005 +0100
ddraw: Fix DirectDrawSurface::QueryInterface crash.
---
dlls/ddraw/surface_main.c | 3 +++
dlls/ddraw/tests/dsurface.c | 28 ++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/dlls/ddraw/surface_main.c b/dlls/ddraw/surface_main.c
index fd10394..ba11359 100644
--- a/dlls/ddraw/surface_main.c
+++ b/dlls/ddraw/surface_main.c
@@ -160,6 +160,9 @@ Main_DirectDrawSurface_QueryInterface(LP
*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 10faf02..e1e0c93 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2005 Antoine Chavasse (a.chavasse at 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();
}
More information about the wine-cvs
mailing list