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
62454ae7
Commit
62454ae7
authored
Jul 31, 2015
by
Henri Verbeet
Committed by
Alexandre Julliard
Jul 31, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wined3d: Validate "data" in wined3d_texture_upload_data().
parent
e5e05b97
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
device.c
dlls/d3d10core/tests/device.c
+8
-0
texture.c
dlls/wined3d/texture.c
+19
-3
No files found.
dlls/d3d10core/tests/device.c
View file @
62454ae7
...
@@ -164,6 +164,7 @@ static IDXGISwapChain *create_swapchain(ID3D10Device *device, HWND window, BOOL
...
@@ -164,6 +164,7 @@ static IDXGISwapChain *create_swapchain(ID3D10Device *device, HWND window, BOOL
static
void
test_create_texture2d
(
void
)
static
void
test_create_texture2d
(
void
)
{
{
ULONG
refcount
,
expected_refcount
;
ULONG
refcount
,
expected_refcount
;
D3D10_SUBRESOURCE_DATA
data
=
{
0
};
ID3D10Device
*
device
,
*
tmp
;
ID3D10Device
*
device
,
*
tmp
;
D3D10_TEXTURE2D_DESC
desc
;
D3D10_TEXTURE2D_DESC
desc
;
ID3D10Texture2D
*
texture
;
ID3D10Texture2D
*
texture
;
...
@@ -188,6 +189,9 @@ static void test_create_texture2d(void)
...
@@ -188,6 +189,9 @@ static void test_create_texture2d(void)
desc
.
CPUAccessFlags
=
0
;
desc
.
CPUAccessFlags
=
0
;
desc
.
MiscFlags
=
0
;
desc
.
MiscFlags
=
0
;
hr
=
ID3D10Device_CreateTexture2D
(
device
,
&
desc
,
&
data
,
&
texture
);
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#x.
\n
"
,
hr
);
expected_refcount
=
get_refcount
((
IUnknown
*
)
device
)
+
1
;
expected_refcount
=
get_refcount
((
IUnknown
*
)
device
)
+
1
;
hr
=
ID3D10Device_CreateTexture2D
(
device
,
&
desc
,
NULL
,
&
texture
);
hr
=
ID3D10Device_CreateTexture2D
(
device
,
&
desc
,
NULL
,
&
texture
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a 2d texture, hr %#x
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a 2d texture, hr %#x
\n
"
,
hr
);
...
@@ -255,6 +259,7 @@ static void test_create_texture2d(void)
...
@@ -255,6 +259,7 @@ static void test_create_texture2d(void)
static
void
test_create_texture3d
(
void
)
static
void
test_create_texture3d
(
void
)
{
{
ULONG
refcount
,
expected_refcount
;
ULONG
refcount
,
expected_refcount
;
D3D10_SUBRESOURCE_DATA
data
=
{
0
};
ID3D10Device
*
device
,
*
tmp
;
ID3D10Device
*
device
,
*
tmp
;
D3D10_TEXTURE3D_DESC
desc
;
D3D10_TEXTURE3D_DESC
desc
;
ID3D10Texture3D
*
texture
;
ID3D10Texture3D
*
texture
;
...
@@ -277,6 +282,9 @@ static void test_create_texture3d(void)
...
@@ -277,6 +282,9 @@ static void test_create_texture3d(void)
desc
.
CPUAccessFlags
=
0
;
desc
.
CPUAccessFlags
=
0
;
desc
.
MiscFlags
=
0
;
desc
.
MiscFlags
=
0
;
hr
=
ID3D10Device_CreateTexture3D
(
device
,
&
desc
,
&
data
,
&
texture
);
ok
(
hr
==
E_INVALIDARG
,
"Got unexpected hr %#x.
\n
"
,
hr
);
expected_refcount
=
get_refcount
((
IUnknown
*
)
device
)
+
1
;
expected_refcount
=
get_refcount
((
IUnknown
*
)
device
)
+
1
;
hr
=
ID3D10Device_CreateTexture3D
(
device
,
&
desc
,
NULL
,
&
texture
);
hr
=
ID3D10Device_CreateTexture3D
(
device
,
&
desc
,
NULL
,
&
texture
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a 3d texture, hr %#x.
\n
"
,
hr
);
ok
(
SUCCEEDED
(
hr
),
"Failed to create a 3d texture, hr %#x.
\n
"
,
hr
);
...
...
dlls/wined3d/texture.c
View file @
62454ae7
...
@@ -727,12 +727,22 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
...
@@ -727,12 +727,22 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
return
WINED3D_OK
;
return
WINED3D_OK
;
}
}
static
void
wined3d_texture_upload_data
(
struct
wined3d_texture
*
texture
,
const
struct
wined3d_sub_resource_data
*
data
)
static
HRESULT
wined3d_texture_upload_data
(
struct
wined3d_texture
*
texture
,
const
struct
wined3d_sub_resource_data
*
data
)
{
{
unsigned
int
sub_count
=
texture
->
level_count
*
texture
->
layer_count
;
unsigned
int
sub_count
=
texture
->
level_count
*
texture
->
layer_count
;
struct
wined3d_context
*
context
;
struct
wined3d_context
*
context
;
unsigned
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
sub_count
;
++
i
)
{
if
(
!
data
[
i
].
data
)
{
WARN
(
"Invalid sub-resource data specified for sub-resource %u.
\n
"
,
i
);
return
E_INVALIDARG
;
}
}
context
=
context_acquire
(
texture
->
resource
.
device
,
NULL
);
context
=
context_acquire
(
texture
->
resource
.
device
,
NULL
);
wined3d_texture_prepare_texture
(
texture
,
context
,
FALSE
);
wined3d_texture_prepare_texture
(
texture
,
context
,
FALSE
);
...
@@ -748,6 +758,8 @@ static void wined3d_texture_upload_data(struct wined3d_texture *texture, const s
...
@@ -748,6 +758,8 @@ static void wined3d_texture_upload_data(struct wined3d_texture *texture, const s
}
}
context_release
(
context
);
context_release
(
context
);
return
WINED3D_OK
;
}
}
static
void
texture2d_sub_resource_load
(
struct
wined3d_resource
*
sub_resource
,
static
void
texture2d_sub_resource_load
(
struct
wined3d_resource
*
sub_resource
,
...
@@ -1444,8 +1456,12 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
...
@@ -1444,8 +1456,12 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
/* FIXME: We'd like to avoid ever allocating system memory for the texture
/* FIXME: We'd like to avoid ever allocating system memory for the texture
* in this case. */
* in this case. */
if
(
data
)
if
(
data
&&
FAILED
(
hr
=
wined3d_texture_upload_data
(
object
,
data
)))
wined3d_texture_upload_data
(
object
,
data
);
{
wined3d_texture_cleanup
(
object
);
HeapFree
(
GetProcessHeap
(),
0
,
object
);
return
hr
;
}
TRACE
(
"Created texture %p.
\n
"
,
object
);
TRACE
(
"Created texture %p.
\n
"
,
object
);
*
texture
=
object
;
*
texture
=
object
;
...
...
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