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
b06a0609
Commit
b06a0609
authored
Apr 28, 2006
by
Robert Reif
Committed by
Alexandre Julliard
May 05, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsound: Check DirectSoundBuffer_Lock parameters.
Check DirectSoundBuffer_Lock parameters and return an error (like Windows) rather than fixing up the parameters.
parent
79e2f0c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
15 deletions
+34
-15
buffer.c
dlls/dsound/buffer.c
+17
-6
primary.c
dlls/dsound/primary.c
+17
-9
No files found.
dlls/dsound/buffer.c
View file @
b06a0609
...
...
@@ -567,21 +567,31 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock(
GetTickCount
()
);
/* when this flag is set, writecursor is meaningless and must be calculated */
if
(
flags
&
DSBLOCK_FROMWRITECURSOR
)
{
DWORD
writepos
;
/* GetCurrentPosition does too much magic to duplicate here */
hres
=
IDirectSoundBufferImpl_GetCurrentPosition
(
iface
,
NULL
,
&
write
pos
);
hres
=
IDirectSoundBufferImpl_GetCurrentPosition
(
iface
,
NULL
,
&
write
cursor
);
if
(
hres
!=
DS_OK
)
{
WARN
(
"IDirectSoundBufferImpl_GetCurrentPosition failed
\n
"
);
return
hres
;
}
writecursor
+=
writepos
;
}
writecursor
%=
This
->
buflen
;
/* when this flag is set, writebytes is meaningless and must be set */
if
(
flags
&
DSBLOCK_ENTIREBUFFER
)
writebytes
=
This
->
buflen
;
if
(
writebytes
>
This
->
buflen
)
writebytes
=
This
->
buflen
;
if
(
writecursor
>=
This
->
buflen
)
{
WARN
(
"Invalid parameter, writecursor: %lu >= buflen: %lu
\n
"
,
writecursor
,
This
->
buflen
);
return
DSERR_INVALIDPARAM
;
}
if
(
writebytes
>
This
->
buflen
)
{
WARN
(
"Invalid parameter, writebytes: %lu > buflen: %lu
\n
"
,
writebytes
,
This
->
buflen
);
return
DSERR_INVALIDPARAM
;
}
EnterCriticalSection
(
&
(
This
->
lock
));
...
...
@@ -648,6 +658,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock(
}
LeaveCriticalSection
(
&
(
This
->
lock
));
return
DS_OK
;
}
...
...
dlls/dsound/primary.c
View file @
b06a0609
...
...
@@ -665,6 +665,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetFormat(
static
HRESULT
WINAPI
PrimaryBufferImpl_Lock
(
LPDIRECTSOUNDBUFFER8
iface
,
DWORD
writecursor
,
DWORD
writebytes
,
LPVOID
lplpaudioptr1
,
LPDWORD
audiobytes1
,
LPVOID
lplpaudioptr2
,
LPDWORD
audiobytes2
,
DWORD
flags
)
{
HRESULT
hres
;
DirectSoundDevice
*
device
=
((
PrimaryBufferImpl
*
)
iface
)
->
device
;
TRACE
(
"(%p,%ld,%ld,%p,%p,%p,%p,0x%08lx) at %ld
\n
"
,
iface
,
...
...
@@ -683,26 +684,33 @@ static HRESULT WINAPI PrimaryBufferImpl_Lock(
return
DSERR_PRIOLEVELNEEDED
;
}
/* when this flag is set, writecursor is meaningless and must be calculated */
if
(
flags
&
DSBLOCK_FROMWRITECURSOR
)
{
DWORD
writepos
;
HRESULT
hres
;
/* GetCurrentPosition does too much magic to duplicate here */
hres
=
IDirectSoundBuffer_GetCurrentPosition
(
iface
,
NULL
,
&
write
pos
);
hres
=
IDirectSoundBuffer_GetCurrentPosition
(
iface
,
NULL
,
&
write
cursor
);
if
(
hres
!=
DS_OK
)
{
WARN
(
"IDirectSoundBuffer_GetCurrentPosition failed
\n
"
);
return
hres
;
}
writecursor
+=
writepos
;
}
while
(
writecursor
>=
device
->
buflen
)
writecursor
-=
device
->
buflen
;
/* when this flag is set, writebytes is meaningless and must be set */
if
(
flags
&
DSBLOCK_ENTIREBUFFER
)
writebytes
=
device
->
buflen
;
if
(
writebytes
>
device
->
buflen
)
writebytes
=
device
->
buflen
;
if
(
writecursor
>=
device
->
buflen
)
{
WARN
(
"Invalid parameter, writecursor: %lu >= buflen: %lu
\n
"
,
writecursor
,
device
->
buflen
);
return
DSERR_INVALIDPARAM
;
}
if
(
writebytes
>
device
->
buflen
)
{
WARN
(
"Invalid parameter, writebytes: %lu > buflen: %lu
\n
"
,
writebytes
,
device
->
buflen
);
return
DSERR_INVALIDPARAM
;
}
if
(
!
(
device
->
drvdesc
.
dwFlags
&
DSDDESC_DONTNEEDPRIMARYLOCK
)
&&
device
->
hwbuf
)
{
HRESULT
hres
;
hres
=
IDsDriverBuffer_Lock
(
device
->
hwbuf
,
lplpaudioptr1
,
audiobytes1
,
lplpaudioptr2
,
audiobytes2
,
...
...
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