Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8e79a7e6
Commit
8e79a7e6
authored
Sep 03, 2011
by
Stefan Dösinger
Committed by
Alexandre Julliard
Sep 07, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Add some NULL pointer tests.
parent
252bead2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
101 additions
and
27 deletions
+101
-27
ddraw.c
dlls/ddraw/ddraw.c
+18
-18
surface.c
dlls/ddraw/surface.c
+17
-9
ddrawmodes.c
dlls/ddraw/tests/ddrawmodes.c
+4
-0
dsurface.c
dlls/ddraw/tests/dsurface.c
+62
-0
No files found.
dlls/ddraw/ddraw.c
View file @
8e79a7e6
...
...
@@ -2308,9 +2308,9 @@ static HRESULT WINAPI ddraw3_EnumDisplayModes(IDirectDraw3 *iface, DWORD flags,
cbcontext
.
func
=
callback
;
cbcontext
.
context
=
context
;
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumDisplayModes
(
&
This
->
IDirectDraw7_iface
,
flags
,
&
surface_desc2
,
&
cbcontext
,
EnumDisplayModesCallbackThunk
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumDisplayModes
(
&
This
->
IDirectDraw7_iface
,
flags
,
surface_desc
?
&
surface_desc2
:
NULL
,
&
cbcontext
,
EnumDisplayModesCallbackThunk
);
}
static
HRESULT
WINAPI
ddraw2_EnumDisplayModes
(
IDirectDraw2
*
iface
,
DWORD
flags
,
...
...
@@ -2326,9 +2326,9 @@ static HRESULT WINAPI ddraw2_EnumDisplayModes(IDirectDraw2 *iface, DWORD flags,
cbcontext
.
func
=
callback
;
cbcontext
.
context
=
context
;
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumDisplayModes
(
&
This
->
IDirectDraw7_iface
,
flags
,
&
surface_desc2
,
&
cbcontext
,
EnumDisplayModesCallbackThunk
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumDisplayModes
(
&
This
->
IDirectDraw7_iface
,
flags
,
surface_desc
?
&
surface_desc2
:
NULL
,
&
cbcontext
,
EnumDisplayModesCallbackThunk
);
}
static
HRESULT
WINAPI
ddraw1_EnumDisplayModes
(
IDirectDraw
*
iface
,
DWORD
flags
,
...
...
@@ -2344,9 +2344,9 @@ static HRESULT WINAPI ddraw1_EnumDisplayModes(IDirectDraw *iface, DWORD flags,
cbcontext
.
func
=
callback
;
cbcontext
.
context
=
context
;
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumDisplayModes
(
&
This
->
IDirectDraw7_iface
,
flags
,
&
surface_desc2
,
&
cbcontext
,
EnumDisplayModesCallbackThunk
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumDisplayModes
(
&
This
->
IDirectDraw7_iface
,
flags
,
surface_desc
?
&
surface_desc2
:
NULL
,
&
cbcontext
,
EnumDisplayModesCallbackThunk
);
}
/*****************************************************************************
...
...
@@ -3730,9 +3730,9 @@ static HRESULT WINAPI ddraw3_EnumSurfaces(IDirectDraw3 *iface, DWORD flags,
cbcontext
.
func
=
callback
;
cbcontext
.
context
=
context
;
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumSurfaces
(
&
This
->
IDirectDraw7_iface
,
flags
,
&
surface_desc2
,
&
cbcontext
,
EnumSurfacesCallbackThunk
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumSurfaces
(
&
This
->
IDirectDraw7_iface
,
flags
,
surface_desc
?
&
surface_desc2
:
NULL
,
&
cbcontext
,
EnumSurfacesCallbackThunk
);
}
static
HRESULT
WINAPI
ddraw2_EnumSurfaces
(
IDirectDraw2
*
iface
,
DWORD
flags
,
...
...
@@ -3748,9 +3748,9 @@ static HRESULT WINAPI ddraw2_EnumSurfaces(IDirectDraw2 *iface, DWORD flags,
cbcontext
.
func
=
callback
;
cbcontext
.
context
=
context
;
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumSurfaces
(
&
This
->
IDirectDraw7_iface
,
flags
,
&
surface_desc2
,
&
cbcontext
,
EnumSurfacesCallbackThunk
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumSurfaces
(
&
This
->
IDirectDraw7_iface
,
flags
,
surface_desc
?
&
surface_desc2
:
NULL
,
&
cbcontext
,
EnumSurfacesCallbackThunk
);
}
static
HRESULT
WINAPI
ddraw1_EnumSurfaces
(
IDirectDraw
*
iface
,
DWORD
flags
,
...
...
@@ -3766,9 +3766,9 @@ static HRESULT WINAPI ddraw1_EnumSurfaces(IDirectDraw *iface, DWORD flags,
cbcontext
.
func
=
callback
;
cbcontext
.
context
=
context
;
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumSurfaces
(
&
This
->
IDirectDraw7_iface
,
flags
,
&
surface_desc2
,
&
cbcontext
,
EnumSurfacesCallbackThunk
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw7_EnumSurfaces
(
&
This
->
IDirectDraw7_iface
,
flags
,
surface_desc
?
&
surface_desc2
:
NULL
,
&
cbcontext
,
EnumSurfacesCallbackThunk
);
}
/*****************************************************************************
...
...
dlls/ddraw/surface.c
View file @
8e79a7e6
...
...
@@ -2938,9 +2938,9 @@ static HRESULT WINAPI ddraw_surface3_Initialize(IDirectDrawSurface3 *iface,
DDSURFACEDESC2
surface_desc2
;
TRACE
(
"iface %p, ddraw %p, surface_desc %p.
\n
"
,
iface
,
ddraw
,
surface_desc
);
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw_surface7_Initialize
(
&
This
->
IDirectDrawSurface7_iface
,
ddraw
,
&
surface_desc2
);
ddraw
,
surface_desc
?
&
surface_desc2
:
NULL
);
}
static
HRESULT
WINAPI
ddraw_surface2_Initialize
(
IDirectDrawSurface2
*
iface
,
...
...
@@ -2950,9 +2950,9 @@ static HRESULT WINAPI ddraw_surface2_Initialize(IDirectDrawSurface2 *iface,
DDSURFACEDESC2
surface_desc2
;
TRACE
(
"iface %p, ddraw %p, surface_desc %p.
\n
"
,
iface
,
ddraw
,
surface_desc
);
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw_surface7_Initialize
(
&
This
->
IDirectDrawSurface7_iface
,
ddraw
,
&
surface_desc2
);
ddraw
,
surface_desc
?
&
surface_desc2
:
NULL
);
}
static
HRESULT
WINAPI
ddraw_surface1_Initialize
(
IDirectDrawSurface
*
iface
,
...
...
@@ -2962,9 +2962,9 @@ static HRESULT WINAPI ddraw_surface1_Initialize(IDirectDrawSurface *iface,
DDSURFACEDESC2
surface_desc2
;
TRACE
(
"iface %p, ddraw %p, surface_desc %p.
\n
"
,
iface
,
ddraw
,
surface_desc
);
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw_surface7_Initialize
(
&
This
->
IDirectDrawSurface7_iface
,
ddraw
,
&
surface_desc2
);
ddraw
,
surface_desc
?
&
surface_desc2
:
NULL
);
}
/*****************************************************************************
...
...
@@ -3873,8 +3873,16 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
TRACE
(
"iface %p, surface_desc %p, flags %#x.
\n
"
,
iface
,
DDSD
,
Flags
);
if
(
!
DDSD
)
if
(
!
DDSD
)
{
WARN
(
"DDSD is NULL, returning DDERR_INVALIDPARAMS
\n
"
);
return
DDERR_INVALIDPARAMS
;
}
if
(
Flags
)
{
WARN
(
"Flags is %x, returning DDERR_INVALIDPARAMS
\n
"
,
Flags
);
return
DDERR_INVALIDPARAMS
;
}
EnterCriticalSection
(
&
ddraw_cs
);
if
(
DDSD
->
dwFlags
&
DDSD_PIXELFORMAT
)
...
...
@@ -3957,9 +3965,9 @@ static HRESULT WINAPI ddraw_surface3_SetSurfaceDesc(IDirectDrawSurface3 *iface,
DDSURFACEDESC2
surface_desc2
;
TRACE
(
"iface %p, surface_desc %p, flags %#x.
\n
"
,
iface
,
surface_desc
,
flags
);
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
if
(
surface_desc
)
DDSD_to_DDSD2
(
surface_desc
,
&
surface_desc2
);
return
ddraw_surface7_SetSurfaceDesc
(
&
This
->
IDirectDrawSurface7_iface
,
&
surface_desc2
,
flags
);
surface_desc
?
&
surface_desc2
:
NULL
,
flags
);
}
/*****************************************************************************
...
...
dlls/ddraw/tests/ddrawmodes.c
View file @
8e79a7e6
...
...
@@ -501,8 +501,12 @@ static void enumdisplaymodes(void)
ok
(
rc
==
DD_OK
,
"EnumDisplayModes returned: %x
\n
"
,
rc
);
ok
(
modes16bpp_cnt
==
refresh_count
,
"Expected %d modes got %d
\n
"
,
refresh_count
,
modes16bpp_cnt
);
}
rc
=
IDirectDraw_EnumDisplayModes
(
lpDD
,
0
,
NULL
,
0
,
enummodescallback
);
ok
(
rc
==
DD_OK
,
"EnumDisplayModes returned: %x
\n
"
,
rc
);
}
static
void
setdisplaymode
(
int
i
)
{
HRESULT
rc
;
...
...
dlls/ddraw/tests/dsurface.c
View file @
8e79a7e6
...
...
@@ -1217,6 +1217,11 @@ static void EnumTest(void)
ok
(
rc
==
DD_OK
,
"IDirectDraw_EnumSurfaces returned %08x
\n
"
,
rc
);
ok
(
ctx
.
count
==
3
,
"%d surfaces enumerated, expected 3
\n
"
,
ctx
.
count
);
ctx
.
count
=
0
;
rc
=
IDirectDraw_EnumSurfaces
(
lpDD
,
DDENUMSURFACES_DOESEXIST
|
DDENUMSURFACES_ALL
,
NULL
,
&
ctx
,
enumCB
);
ok
(
rc
==
DD_OK
,
"IDirectDraw_EnumSurfaces returned %08x
\n
"
,
rc
);
ok
(
ctx
.
count
==
3
,
"%d surfaces enumerated, expected 3
\n
"
,
ctx
.
count
);
IDirectDrawSurface_Release
(
ctx
.
expected
[
2
]);
IDirectDrawSurface_Release
(
ctx
.
expected
[
1
]);
IDirectDrawSurface_Release
(
surface
);
...
...
@@ -1944,6 +1949,10 @@ static void test_lockrect_invalid(void)
continue
;
}
hr
=
IDirectDrawSurface_Lock
(
surface
,
NULL
,
NULL
,
DDLOCK_WAIT
,
NULL
);
ok
(
hr
==
DDERR_INVALIDPARAMS
,
"Lock returned 0x%08x for NULL DDSURFACEDESC,"
" expected DDERR_INVALIDPARAMS (0x%08x)
\n
"
,
hr
,
DDERR_INVALIDPARAMS
);
for
(
i
=
0
;
i
<
(
sizeof
(
valid
)
/
sizeof
(
*
valid
));
++
i
)
{
RECT
*
rect
=
&
valid
[
i
];
...
...
@@ -4216,6 +4225,58 @@ static void pixelformat_flag_test(void)
test_ddsd
(
&
ddsd
,
FALSE
,
TRUE
,
"Z buffer"
);
}
static
void
set_surface_desc_test
(
void
)
{
HRESULT
hr
;
DDSURFACEDESC
ddsd
;
IDirectDrawSurface
*
surface
;
IDirectDrawSurface3
*
surface3
;
BYTE
data
[
8
*
8
*
4
];
hr
=
IDirectDraw_CreateSurface
(
lpDD
,
NULL
,
&
surface
,
NULL
);
ok
(
hr
==
DDERR_INVALIDPARAMS
,
"CreateSurface with a NULL DDSD returned %#x,"
" expected DDERR_INVALIDPARAMS(%#x)
\n
"
,
hr
,
DDERR_INVALIDPARAMS
);
reset_ddsd
(
&
ddsd
);
ddsd
.
dwFlags
=
DDSD_WIDTH
|
DDSD_HEIGHT
|
DDSD_CAPS
|
DDSD_PIXELFORMAT
;
ddsd
.
dwWidth
=
8
;
ddsd
.
dwHeight
=
8
;
ddsd
.
ddpfPixelFormat
.
dwSize
=
sizeof
(
ddsd
.
ddpfPixelFormat
);
ddsd
.
ddpfPixelFormat
.
dwFlags
=
DDPF_RGB
;
U1
(
ddsd
.
ddpfPixelFormat
).
dwRGBBitCount
=
32
;
U2
(
ddsd
.
ddpfPixelFormat
).
dwRBitMask
=
0x00ff0000
;
U3
(
ddsd
.
ddpfPixelFormat
).
dwGBitMask
=
0x0000ff00
;
U4
(
ddsd
.
ddpfPixelFormat
).
dwBBitMask
=
0x000000ff
;
ddsd
.
ddsCaps
.
dwCaps
=
DDSCAPS_SYSTEMMEMORY
;
hr
=
IDirectDraw_CreateSurface
(
lpDD
,
&
ddsd
,
&
surface
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"IDirectDraw_CreateSurface failed, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface_QueryInterface
(
surface
,
&
IID_IDirectDrawSurface3
,
(
void
**
)
&
surface3
);
ok
(
SUCCEEDED
(
hr
),
"IDirectDrawSurface_QueryInterface failed, hr %#x.
\n
"
,
hr
);
IDirectDrawSurface_Release
(
surface
);
reset_ddsd
(
&
ddsd
);
ddsd
.
dwFlags
=
DDSD_LPSURFACE
;
ddsd
.
lpSurface
=
data
;
hr
=
IDirectDrawSurface3_SetSurfaceDesc
(
surface3
,
&
ddsd
,
0
);
ok
(
SUCCEEDED
(
hr
),
"IDirectDrawSurface3_SetSurfaceDesc failed, hr %#x.
\n
"
,
hr
);
/* Redundantly setting the same lpSurface is not an error */
hr
=
IDirectDrawSurface3_SetSurfaceDesc
(
surface3
,
&
ddsd
,
0
);
ok
(
SUCCEEDED
(
hr
),
"IDirectDrawSurface3_SetSurfaceDesc failed, hr %#x.
\n
"
,
hr
);
hr
=
IDirectDrawSurface3_SetSurfaceDesc
(
surface3
,
&
ddsd
,
1
);
ok
(
hr
==
DDERR_INVALIDPARAMS
,
"IDirectDrawSurface3_SetSurfaceDesc returned %#x, expected"
" DDERR_INVALIDPARAMS(%#x)
\n
"
,
hr
,
DDERR_INVALIDPARAMS
);
hr
=
IDirectDrawSurface3_SetSurfaceDesc
(
surface3
,
NULL
,
0
);
ok
(
hr
==
DDERR_INVALIDPARAMS
,
"IDirectDrawSurface3_SetSurfaceDesc returned %#x, expected"
" DDERR_INVALIDPARAMS(%#x)
\n
"
,
hr
,
DDERR_INVALIDPARAMS
);
IDirectDrawSurface_Release
(
surface3
);
}
START_TEST
(
dsurface
)
{
HRESULT
ret
;
...
...
@@ -4275,5 +4336,6 @@ START_TEST(dsurface)
no_ddsd_caps_test
();
zbufferbitdepth_test
();
pixelformat_flag_test
();
set_surface_desc_test
();
ReleaseDirectDraw
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment