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
40dff81b
Commit
40dff81b
authored
Sep 16, 2007
by
James Hawkins
Committed by
Alexandre Julliard
Sep 17, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix the case where memory is freed twice in GlobalFree.
parent
2cd2f122
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
49 deletions
+41
-49
heap.c
dlls/kernel32/heap.c
+5
-1
heap.c
dlls/kernel32/tests/heap.c
+12
-0
dde.c
dlls/user32/tests/dde.c
+24
-48
No files found.
dlls/kernel32/heap.c
View file @
40dff81b
...
...
@@ -741,7 +741,11 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
hreturned
=
0
;
if
(
ISPOINTER
(
hmem
))
/* POINTER */
{
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
(
LPVOID
)
hmem
))
hmem
=
0
;
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
(
LPVOID
)
hmem
))
{
SetLastError
(
ERROR_INVALID_HANDLE
);
hreturned
=
hmem
;
}
}
else
/* HANDLE */
{
...
...
dlls/kernel32/tests/heap.c
View file @
40dff81b
...
...
@@ -176,6 +176,18 @@ START_TEST(heap)
"returned %d with %d (expected ERROR_INVALID_HANDLE)
\n
"
,
res
,
GetLastError
());
gbl
=
GlobalAlloc
(
GMEM_DDESHARE
,
100
);
/* first free */
mem
=
GlobalFree
(
gbl
);
ok
(
mem
==
NULL
,
"Expected NULL, got %p
\n
"
,
mem
);
/* invalid free */
SetLastError
(
MAGIC_DEAD
);
mem
=
GlobalFree
(
gbl
);
ok
(
mem
==
gbl
,
"Expected gbl, got %p
\n
"
,
mem
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
/* ####################################### */
/* Local*() functions */
...
...
dlls/user32/tests/dde.c
View file @
40dff81b
...
...
@@ -399,12 +399,9 @@ static void test_FreeDDElParam(void)
ret
=
FreeDDElParam
(
WM_DDE_ADVISE
,
(
LPARAM
)
hglobal
);
ok
(
ret
==
TRUE
,
"Expected TRUE, got %d
\n
"
,
ret
);
val
=
GlobalFree
(
hglobal
);
todo_wine
{
ok
(
val
==
hglobal
,
"Expected hglobal, got %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
ok
(
val
==
hglobal
,
"Expected hglobal, got %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
hglobal
=
GlobalAlloc
(
GMEM_DDESHARE
,
100
);
ret
=
FreeDDElParam
(
WM_DDE_UNADVISE
,
(
LPARAM
)
hglobal
);
...
...
@@ -416,23 +413,17 @@ static void test_FreeDDElParam(void)
ret
=
FreeDDElParam
(
WM_DDE_ACK
,
(
LPARAM
)
hglobal
);
ok
(
ret
==
TRUE
,
"Expected TRUE, got %d
\n
"
,
ret
);
val
=
GlobalFree
(
hglobal
);
todo_wine
{
ok
(
val
==
hglobal
,
"Expected hglobal, got %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
ok
(
val
==
hglobal
,
"Expected hglobal, got %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
hglobal
=
GlobalAlloc
(
GMEM_DDESHARE
,
100
);
ret
=
FreeDDElParam
(
WM_DDE_DATA
,
(
LPARAM
)
hglobal
);
ok
(
ret
==
TRUE
,
"Expected TRUE, got %d
\n
"
,
ret
);
val
=
GlobalFree
(
hglobal
);
todo_wine
{
ok
(
val
==
hglobal
,
"Expected hglobal, got %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
ok
(
val
==
hglobal
,
"Expected hglobal, got %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
hglobal
=
GlobalAlloc
(
GMEM_DDESHARE
,
100
);
ret
=
FreeDDElParam
(
WM_DDE_REQUEST
,
(
LPARAM
)
hglobal
);
...
...
@@ -444,12 +435,9 @@ static void test_FreeDDElParam(void)
ret
=
FreeDDElParam
(
WM_DDE_POKE
,
(
LPARAM
)
hglobal
);
ok
(
ret
==
TRUE
,
"Expected TRUE, got %d
\n
"
,
ret
);
val
=
GlobalFree
(
hglobal
);
todo_wine
{
ok
(
val
==
hglobal
,
"Expected hglobal, got %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
ok
(
val
==
hglobal
,
"Expected hglobal, got %p
\n
"
,
val
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
hglobal
=
GlobalAlloc
(
GMEM_DDESHARE
,
100
);
ret
=
FreeDDElParam
(
WM_DDE_EXECUTE
,
(
LPARAM
)
hglobal
);
...
...
@@ -519,12 +507,9 @@ static void test_PackDDElParam(void)
ok
(
ret
==
TRUE
,
"Expected TRUE, got %d
\n
"
,
ret
);
hglobal
=
GlobalFree
((
HGLOBAL
)
lparam
);
todo_wine
{
ok
(
hglobal
==
(
HGLOBAL
)
lparam
,
"Expected lparam, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
ok
(
hglobal
==
(
HGLOBAL
)
lparam
,
"Expected lparam, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
lparam
=
PackDDElParam
(
WM_DDE_UNADVISE
,
0xcafe
,
0xbeef
);
ok
(
lparam
==
0xbeefcafe
,
"Expected 0xbeefcafe, got %08lx
\n
"
,
lparam
);
...
...
@@ -564,12 +549,9 @@ static void test_PackDDElParam(void)
ok
(
ret
==
TRUE
,
"Expected TRUE, got %d
\n
"
,
ret
);
hglobal
=
GlobalFree
((
HGLOBAL
)
lparam
);
todo_wine
{
ok
(
hglobal
==
(
HGLOBAL
)
lparam
,
"Expected lparam, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
ok
(
hglobal
==
(
HGLOBAL
)
lparam
,
"Expected lparam, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
lparam
=
PackDDElParam
(
WM_DDE_DATA
,
0xcafe
,
0xbeef
);
ptr
=
GlobalLock
((
HGLOBAL
)
lparam
);
...
...
@@ -593,12 +575,9 @@ static void test_PackDDElParam(void)
ok
(
ret
==
TRUE
,
"Expected TRUE, got %d
\n
"
,
ret
);
hglobal
=
GlobalFree
((
HGLOBAL
)
lparam
);
todo_wine
{
ok
(
hglobal
==
(
HGLOBAL
)
lparam
,
"Expected lparam, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
ok
(
hglobal
==
(
HGLOBAL
)
lparam
,
"Expected lparam, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
lparam
=
PackDDElParam
(
WM_DDE_REQUEST
,
0xcafe
,
0xbeef
);
ok
(
lparam
==
0xbeefcafe
,
"Expected 0xbeefcafe, got %08lx
\n
"
,
lparam
);
...
...
@@ -638,12 +617,9 @@ static void test_PackDDElParam(void)
ok
(
ret
==
TRUE
,
"Expected TRUE, got %d
\n
"
,
ret
);
hglobal
=
GlobalFree
((
HGLOBAL
)
lparam
);
todo_wine
{
ok
(
hglobal
==
(
HGLOBAL
)
lparam
,
"Expected lparam, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
}
ok
(
hglobal
==
(
HGLOBAL
)
lparam
,
"Expected lparam, got %d
\n
"
,
ret
);
ok
(
GetLastError
()
==
ERROR_INVALID_HANDLE
,
"Expected ERROR_INVALID_HANDLE, got %d
\n
"
,
GetLastError
());
lparam
=
PackDDElParam
(
WM_DDE_EXECUTE
,
0xcafe
,
0xbeef
);
ok
(
lparam
==
0xbeef
,
"Expected 0xbeef, got %08lx
\n
"
,
lparam
);
...
...
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