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
598c5816
Commit
598c5816
authored
Mar 28, 2014
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Don't allocate FLS index 0.
parent
93920c38
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
4 deletions
+34
-4
fiber.c
dlls/kernel32/fiber.c
+3
-3
process.c
dlls/kernel32/process.c
+1
-1
fiber.c
dlls/kernel32/tests/fiber.c
+29
-0
thread.c
dlls/ntdll/thread.c
+1
-0
No files found.
dlls/kernel32/fiber.c
View file @
598c5816
...
...
@@ -230,7 +230,7 @@ DWORD WINAPI FlsAlloc( PFLS_CALLBACK_FUNCTION callback )
}
else
{
index
=
RtlFindClearBitsAndSet
(
peb
->
FlsBitmap
,
1
,
0
);
index
=
RtlFindClearBitsAndSet
(
peb
->
FlsBitmap
,
1
,
1
);
if
(
index
!=
~
0U
)
{
if
(
!
NtCurrentTeb
()
->
FlsSlots
&&
...
...
@@ -279,7 +279,7 @@ BOOL WINAPI FlsFree( DWORD index )
*/
PVOID
WINAPI
FlsGetValue
(
DWORD
index
)
{
if
(
index
>=
8
*
sizeof
(
NtCurrentTeb
()
->
Peb
->
FlsBitmapBits
)
||
!
NtCurrentTeb
()
->
FlsSlots
)
if
(
!
index
||
index
>=
8
*
sizeof
(
NtCurrentTeb
()
->
Peb
->
FlsBitmapBits
)
||
!
NtCurrentTeb
()
->
FlsSlots
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
...
...
@@ -293,7 +293,7 @@ PVOID WINAPI FlsGetValue( DWORD index )
*/
BOOL
WINAPI
FlsSetValue
(
DWORD
index
,
PVOID
data
)
{
if
(
index
>=
8
*
sizeof
(
NtCurrentTeb
()
->
Peb
->
FlsBitmapBits
))
if
(
!
index
||
index
>=
8
*
sizeof
(
NtCurrentTeb
()
->
Peb
->
FlsBitmapBits
))
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
...
...
dlls/kernel32/process.c
View file @
598c5816
...
...
@@ -2768,7 +2768,7 @@ DWORD WINAPI TlsAlloc( void )
PEB
*
const
peb
=
NtCurrentTeb
()
->
Peb
;
RtlAcquirePebLock
();
index
=
RtlFindClearBitsAndSet
(
peb
->
TlsBitmap
,
1
,
0
);
index
=
RtlFindClearBitsAndSet
(
peb
->
TlsBitmap
,
1
,
1
);
if
(
index
!=
~
0U
)
NtCurrentTeb
()
->
TlsSlots
[
index
]
=
0
;
/* clear the value */
else
{
...
...
dlls/kernel32/tests/fiber.c
View file @
598c5816
...
...
@@ -181,6 +181,35 @@ static void test_FiberLocalStorage(PFLS_CALLBACK_FUNCTION cbfunc)
ok
(
ret
,
"FlsFree failed
\n
"
);
if
(
cbfunc
)
todo_wine
ok
(
cbCount
==
1
,
"Wrong callback count: %d
\n
"
,
cbCount
);
/* test index 0 */
SetLastError
(
0xdeadbeef
);
val
=
pFlsGetValue
(
0
);
ok
(
!
val
,
"fls index 0 set to %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"setting fls index wrong error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
pFlsSetValue
(
0
,
(
void
*
)
0xdeadbeef
);
ok
(
!
ret
,
"setting fls index 0 succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"setting fls index wrong error %u
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
val
=
pFlsGetValue
(
0
);
ok
(
!
val
,
"fls index 0 wrong value %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"setting fls index wrong error %u
\n
"
,
GetLastError
()
);
fls
=
pFlsAlloc
(
NULL
);
ok
(
fls
!=
FLS_OUT_OF_INDEXES
,
"FlsAlloc failed
\n
"
);
ok
(
fls
!=
0
,
"fls index 0 allocated
\n
"
);
val
=
pFlsGetValue
(
fls
);
ok
(
!
val
,
"fls index %u wrong value %p
\n
"
,
fls
,
val
);
ret
=
pFlsSetValue
(
fls
,
(
void
*
)
0xdeadbeef
);
ok
(
ret
,
"setting fls index %u failed
\n
"
,
fls
);
val
=
pFlsGetValue
(
fls
);
ok
(
val
==
(
void
*
)
0xdeadbeef
,
"fls index %u wrong value %p
\n
"
,
fls
,
val
);
pFlsFree
(
fls
);
ret
=
pFlsSetValue
(
fls
,
(
void
*
)
0xdeadbabe
);
ok
(
ret
,
"setting fls index %u failed
\n
"
,
fls
);
val
=
pFlsGetValue
(
fls
);
ok
(
val
==
(
void
*
)
0xdeadbabe
,
"fls index %u wrong value %p
\n
"
,
fls
,
val
);
}
START_TEST
(
fiber
)
...
...
dlls/ntdll/thread.c
View file @
598c5816
...
...
@@ -257,6 +257,7 @@ HANDLE thread_init(void)
sizeof
(
peb
->
TlsExpansionBitmapBits
)
*
8
);
RtlInitializeBitMap
(
&
fls_bitmap
,
peb
->
FlsBitmapBits
,
sizeof
(
peb
->
FlsBitmapBits
)
*
8
);
RtlSetBits
(
peb
->
TlsBitmap
,
0
,
1
);
/* TLS index 0 is reserved and should be initialized to NULL. */
RtlSetBits
(
peb
->
FlsBitmap
,
0
,
1
);
InitializeListHead
(
&
peb
->
FlsListHead
);
InitializeListHead
(
&
ldr
.
InLoadOrderModuleList
);
InitializeListHead
(
&
ldr
.
InMemoryOrderModuleList
);
...
...
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