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
5c928bc0
Commit
5c928bc0
authored
Nov 09, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Nov 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Test more Global/Local functions with invalid pointers.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=53741
parent
ef25dd24
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
30 deletions
+79
-30
heap.c
dlls/kernel32/tests/heap.c
+79
-30
No files found.
dlls/kernel32/tests/heap.c
View file @
5c928bc0
...
...
@@ -241,34 +241,36 @@ static void test_HeapCreate(void)
ok
(
ret
,
"HeapFree failed, error %lu
\n
"
,
GetLastError
()
);
ret
=
HeapFree
(
heap
,
0
,
NULL
);
ok
(
ret
,
"HeapFree failed, error %lu
\n
"
,
GetLastError
()
);
#if 0 /* crashes */
SetLastError( 0xdeadbeef );
ret = HeapFree( heap, 0, (void *)0xdeadbe00 );
ok( !ret, "HeapFree succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS, "got error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
ptr = (BYTE *)((UINT_PTR)buffer & ~63) + 64;
ret = HeapFree( heap, 0, ptr );
ok( !ret, "HeapFree succeeded\n" );
ok( GetLastError() == 0xdeadbeef, "got error %lu\n", GetLastError() );
#endif
if
(
0
)
/* crashes */
{
SetLastError
(
0xdeadbeef
);
ret
=
HeapFree
(
heap
,
0
,
(
void
*
)
0xdeadbe00
);
ok
(
!
ret
,
"HeapFree succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_NOACCESS
,
"got error %lu
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ptr
=
(
BYTE
*
)((
UINT_PTR
)
buffer
&
~
63
)
+
64
;
ret
=
HeapFree
(
heap
,
0
,
ptr
);
ok
(
!
ret
,
"HeapFree succeeded
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"got error %lu
\n
"
,
GetLastError
()
);
}
SetLastError
(
0xdeadbeef
);
ptr
=
HeapReAlloc
(
heap
,
0
,
NULL
,
1
);
ok
(
!
ptr
,
"HeapReAlloc succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
NO_ERROR
,
"got error %lu
\n
"
,
GetLastError
()
);
#if 0 /* crashes */
SetLastError( 0xdeadbeef );
ptr1 = HeapReAlloc( heap, 0, (void *)0xdeadbe00, 1 );
ok( !ptr1, "HeapReAlloc succeeded\n" );
ok( GetLastError() == ERROR_NOACCESS, "got error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
ptr = (BYTE *)((UINT_PTR)buffer & ~63) + 64;
ptr1 = HeapReAlloc( heap, 0, ptr, 1 );
ok( !ptr1, "HeapReAlloc succeeded\n" );
ok( GetLastError() == 0xdeadbeef, "got error %lu\n", GetLastError() );
#endif
if
(
0
)
/* crashes */
{
SetLastError
(
0xdeadbeef
);
ptr1
=
HeapReAlloc
(
heap
,
0
,
(
void
*
)
0xdeadbe00
,
1
);
ok
(
!
ptr1
,
"HeapReAlloc succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_NOACCESS
,
"got error %lu
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ptr
=
(
BYTE
*
)((
UINT_PTR
)
buffer
&
~
63
)
+
64
;
ptr1
=
HeapReAlloc
(
heap
,
0
,
ptr
,
1
);
ok
(
!
ptr1
,
"HeapReAlloc succeeded
\n
"
);
ok
(
GetLastError
()
==
0xdeadbeef
,
"got error %lu
\n
"
,
GetLastError
()
);
}
SetLastError
(
0xdeadbeef
);
ret
=
HeapValidate
(
heap
,
0
,
NULL
);
...
...
@@ -1557,14 +1559,18 @@ static void test_GlobalAlloc(void)
todo_wine
ok
(
ret
,
"GlobalUnlock failed, error %lu
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
#if 0 /* corrupts Wine heap */
SetLastError
(
0xdeadbeef
);
tmp_mem
=
GlobalReAlloc
(
mem
,
0
,
GMEM_MOVEABLE
);
todo_wine
ok
(
!
tmp_mem
,
"GlobalReAlloc succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
#endif
if
(
sizeof
(
void
*
)
!=
8
)
/* crashes on 64-bit */
{
SetLastError
(
0xdeadbeef
);
tmp_mem
=
GlobalHandle
(
mem
);
ok
(
!
tmp_mem
,
"GlobalHandle succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
}
/* invalid handles are caught */
SetLastError
(
0xdeadbeef
);
...
...
@@ -1592,6 +1598,20 @@ static void test_GlobalAlloc(void)
tmp_mem
=
GlobalReAlloc
(
invalid_mem
,
0
,
GMEM_MOVEABLE
);
ok
(
!
tmp_mem
,
"GlobalReAlloc succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
if
(
sizeof
(
void
*
)
!=
8
)
/* crashes on 64-bit */
{
SetLastError
(
0xdeadbeef
);
tmp_mem
=
GlobalHandle
(
invalid_mem
);
ok
(
!
tmp_mem
,
"GlobalHandle succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
ret
=
pRtlGetUserInfoHeap
(
GetProcessHeap
(),
0
,
invalid_mem
,
(
void
**
)
&
tmp_ptr
,
&
tmp_flags
);
todo_wine
ok
(
!
ret
,
"RtlGetUserInfoHeap failed, error %lu
\n
"
,
GetLastError
()
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"got error %lu
\n
"
,
GetLastError
()
);
}
/* invalid pointers are caught */
SetLastError
(
0xdeadbeef
);
...
...
@@ -1624,6 +1644,18 @@ static void test_GlobalAlloc(void)
ok
(
!
tmp_mem
,
"GlobalReAlloc succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_NOACCESS
,
"got error %lu
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
tmp_mem
=
GlobalHandle
(
invalid_ptr
);
ok
(
!
tmp_mem
,
"GlobalHandle succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
if
(
0
)
/* crashes */
{
SetLastError
(
0xdeadbeef
);
ret
=
pRtlGetUserInfoHeap
(
GetProcessHeap
(),
0
,
invalid_ptr
,
(
void
**
)
&
tmp_ptr
,
&
tmp_flags
);
ok
(
ret
,
"RtlGetUserInfoHeap failed, error %lu
\n
"
,
GetLastError
()
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
}
/* GMEM_FIXED block doesn't allow resize, though it succeeds with GMEM_MODIFY */
mem
=
GlobalAlloc
(
GMEM_FIXED
,
10
);
...
...
@@ -1912,14 +1944,18 @@ static void test_LocalAlloc(void)
ret
=
LocalUnlock
(
mem
);
ok
(
!
ret
,
"LocalUnlock succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
#if 0 /* corrupts Wine heap */
SetLastError
(
0xdeadbeef
);
tmp_mem
=
LocalReAlloc
(
mem
,
0
,
LMEM_MOVEABLE
);
todo_wine
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
#endif
if
(
sizeof
(
void
*
)
!=
8
)
/* crashes on 64-bit */
{
SetLastError
(
0xdeadbeef
);
tmp_mem
=
LocalHandle
(
mem
);
ok
(
!
tmp_mem
,
"LocalHandle succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
}
/* invalid handles are caught */
SetLastError
(
0xdeadbeef
);
...
...
@@ -1946,6 +1982,14 @@ static void test_LocalAlloc(void)
tmp_mem
=
LocalReAlloc
(
invalid_mem
,
0
,
LMEM_MOVEABLE
);
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
if
(
sizeof
(
void
*
)
!=
8
)
/* crashes on 64-bit */
{
SetLastError
(
0xdeadbeef
);
tmp_mem
=
LocalHandle
(
invalid_mem
);
ok
(
!
tmp_mem
,
"LocalHandle succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"got error %lu
\n
"
,
GetLastError
()
);
}
/* invalid pointers are caught */
SetLastError
(
0xdeadbeef
);
...
...
@@ -1977,6 +2021,11 @@ static void test_LocalAlloc(void)
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_NOACCESS
,
"got error %lu
\n
"
,
GetLastError
()
);
SetLastError
(
0xdeadbeef
);
tmp_mem
=
LocalHandle
(
invalid_ptr
);
ok
(
!
tmp_mem
,
"LocalHandle succeeded
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_NOACCESS
,
"got error %lu
\n
"
,
GetLastError
()
);
/* LMEM_FIXED block doesn't allow resize, though it succeeds with LMEM_MODIFY */
mem
=
LocalAlloc
(
LMEM_FIXED
,
10
);
...
...
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