Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
cf9f1859
Commit
cf9f1859
authored
Sep 13, 2016
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: GMEM_FIXED blocks cannot be 0 size.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
55efd7cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
heap.c
dlls/kernel32/heap.c
+11
-5
heap.c
dlls/kernel32/tests/heap.c
+13
-0
No files found.
dlls/kernel32/heap.c
View file @
cf9f1859
...
...
@@ -362,7 +362,7 @@ HGLOBAL WINAPI GlobalAlloc(
if
((
flags
&
GMEM_MOVEABLE
)
==
0
)
/* POINTER */
{
palloc
=
HeapAlloc
(
GetProcessHeap
(),
hpflags
,
size
);
palloc
=
HeapAlloc
(
GetProcessHeap
(),
hpflags
,
max
(
1
,
size
)
);
TRACE
(
"(flags=%04x) returning %p
\n
"
,
flags
,
palloc
);
return
palloc
;
}
...
...
@@ -961,10 +961,16 @@ SIZE_T WINAPI GlobalCompact( DWORD minfree )
* Windows memory management does not provide a separate local heap
* and global heap.
*/
HLOCAL
WINAPI
LocalAlloc
(
UINT
flags
,
/* [in] Allocation attributes */
SIZE_T
size
/* [in] Number of bytes to allocate */
)
{
HLOCAL
WINAPI
LocalAlloc
(
UINT
flags
,
SIZE_T
size
)
{
/* LocalAlloc allows a 0-size fixed block, but GlobalAlloc doesn't */
if
(
!
(
flags
&
LMEM_MOVEABLE
))
{
DWORD
heap_flags
=
(
flags
&
LMEM_ZEROINIT
)
?
HEAP_ZERO_MEMORY
:
0
;
void
*
ret
=
HeapAlloc
(
GetProcessHeap
(),
heap_flags
,
size
);
TRACE
(
"(flags=%04x) returning %p
\n
"
,
flags
,
ret
);
return
ret
;
}
return
GlobalAlloc
(
flags
,
size
);
}
...
...
dlls/kernel32/tests/heap.c
View file @
cf9f1859
...
...
@@ -306,6 +306,12 @@ static void test_heap(void)
"Expected ERROR_INVALID_HANDLE or ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
}
gbl
=
GlobalAlloc
(
GMEM_FIXED
,
0
);
SetLastError
(
0xdeadbeef
);
size
=
GlobalSize
(
gbl
);
ok
(
size
==
1
,
"wrong size %lu
\n
"
,
size
);
GlobalFree
(
gbl
);
/* ####################################### */
/* Local*() functions */
gbl
=
LocalAlloc
(
LMEM_MOVEABLE
,
0
);
...
...
@@ -438,6 +444,13 @@ static void test_heap(void)
broken
(
GetLastError
()
==
0xdeadbeef
)
/* win9x */
,
"got %d
\n
"
,
GetLastError
());
LocalFree
(
gbl
);
gbl
=
LocalAlloc
(
LMEM_FIXED
,
0
);
SetLastError
(
0xdeadbeef
);
size
=
LocalSize
(
gbl
);
ok
(
!
size
||
broken
(
size
==
1
),
/* vistau64 */
"wrong size %lu
\n
"
,
size
);
LocalFree
(
gbl
);
/* trying to lock empty memory should give an error */
gbl
=
GlobalAlloc
(
GMEM_MOVEABLE
|
GMEM_ZEROINIT
,
0
);
ok
(
gbl
!=
NULL
,
"returned NULL
\n
"
);
...
...
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