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
1a81f4ff
Commit
1a81f4ff
authored
Mar 29, 2006
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Mar 30, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel: Fix handling of invalid parameter in GlobalFlags().
parent
5ca18a11
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
10 deletions
+24
-10
heap.c
dlls/kernel/heap.c
+10
-9
heap.c
dlls/kernel/tests/heap.c
+14
-1
No files found.
dlls/kernel/heap.c
View file @
1a81f4ff
...
...
@@ -837,16 +837,16 @@ VOID WINAPI GlobalUnfix(HGLOBAL hmem)
*
* Get information about a global memory object.
*
*
NOTE
S
*
Should this return GMEM_INVALID_HANDLE on invalid handle?
*
PARAM
S
*
hmem [I] Handle of the global memory object
*
* RETURNS
* Value specifying allocation flags and lock count
* GMEM_INVALID_HANDLE: Failure
* Failure: GMEM_INVALID_HANDLE, when the provided handle is invalid
* Success: Value specifying allocation flags and lock count
*
*/
UINT
WINAPI
GlobalFlags
(
HGLOBAL
hmem
/* [in] Handle to global memory object */
)
{
UINT
WINAPI
GlobalFlags
(
HGLOBAL
hmem
)
{
DWORD
retval
;
PGLOBAL32_INTERN
pintern
;
...
...
@@ -866,8 +866,9 @@ UINT WINAPI GlobalFlags(
}
else
{
WARN
(
"Invalid handle: %p
\n
"
,
hmem
);
retval
=
0
;
WARN
(
"invalid handle %p (Magic: 0x%04x)
\n
"
,
hmem
,
pintern
->
Magic
);
SetLastError
(
ERROR_INVALID_HANDLE
);
retval
=
GMEM_INVALID_HANDLE
;
}
RtlUnlockHeap
(
GetProcessHeap
());
}
...
...
dlls/kernel/tests/heap.c
View file @
1a81f4ff
...
...
@@ -36,6 +36,7 @@ static SIZE_T resize_9x(SIZE_T size)
START_TEST
(
heap
)
{
void
*
mem
;
UINT
flags
;
HGLOBAL
gbl
;
HGLOBAL
hsecond
;
SIZE_T
size
;
...
...
@@ -86,6 +87,12 @@ START_TEST(heap)
ok
(
(
hsecond
==
gbl
)
&&
(
GetLastError
()
==
ERROR_INVALID_HANDLE
),
"returned %p with 0x%08lx (expected %p with ERROR_INVALID_HANDLE)
\n
"
,
hsecond
,
GetLastError
(),
gbl
);
SetLastError
(
MAGIC_DEAD
);
flags
=
GlobalFlags
(
gbl
);
ok
(
(
flags
==
GMEM_INVALID_HANDLE
)
&&
(
GetLastError
()
==
ERROR_INVALID_HANDLE
),
"returned 0x%04x with 0x%08lx (expected GMEM_INVALID_HANDLE with "
\
"ERROR_INVALID_HANDLE)
\n
"
,
flags
,
GetLastError
());
/* Local*() functions */
gbl
=
LocalAlloc
(
LMEM_MOVEABLE
,
0
);
...
...
@@ -109,13 +116,19 @@ START_TEST(heap)
ok
(
gbl
==
NULL
,
"local realloc allocated memory
\n
"
);
/* invalid handles are catched in windows */
gbl
=
LocalAlloc
(
G
MEM_MOVEABLE
,
256
);
gbl
=
LocalAlloc
(
L
MEM_MOVEABLE
,
256
);
LocalFree
(
gbl
);
SetLastError
(
MAGIC_DEAD
);
hsecond
=
LocalFree
(
gbl
);
/* invalid handle: free memory twice */
ok
(
(
hsecond
==
gbl
)
&&
(
GetLastError
()
==
ERROR_INVALID_HANDLE
),
"returned %p with 0x%08lx (expected %p with ERROR_INVALID_HANDLE)
\n
"
,
hsecond
,
GetLastError
(),
gbl
);
SetLastError
(
MAGIC_DEAD
);
flags
=
LocalFlags
(
gbl
);
ok
(
(
flags
==
LMEM_INVALID_HANDLE
)
&&
(
GetLastError
()
==
ERROR_INVALID_HANDLE
),
"returned 0x%04x with 0x%08lx (expected LMEM_INVALID_HANDLE with "
\
"ERROR_INVALID_HANDLE)
\n
"
,
flags
,
GetLastError
());
/* trying to lock empty memory should give an error */
gbl
=
GlobalAlloc
(
GMEM_MOVEABLE
|
GMEM_ZEROINIT
,
0
);
...
...
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