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
86d09091
Commit
86d09091
authored
Nov 19, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Nov 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Handle LMEM_MODIFY flag first in LocalReAlloc.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=53474
parent
2be9b0ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
36 deletions
+8
-36
heap.c
dlls/kernel32/tests/heap.c
+2
-29
memory.c
dlls/kernelbase/memory.c
+6
-7
No files found.
dlls/kernel32/tests/heap.c
View file @
86d09091
...
...
@@ -1740,7 +1740,7 @@ static void test_GlobalAlloc(void)
if
(
flags
==
GMEM_MOVEABLE
)
ok
(
size
==
512
,
"GlobalSize returned %Iu
\n
"
,
size
);
else
{
todo_wine_if
(
flags
&&
(
flags
&
GMEM_MOVE
ABLE
)
&&
!
(
flags
&
GMEM_MODIFY
))
todo_wine_if
(
(
flags
&
GMEM_DISCARD
ABLE
)
&&
!
(
flags
&
GMEM_MODIFY
))
ok
(
size
==
10
,
"GlobalSize returned %Iu
\n
"
,
size
);
}
...
...
@@ -1774,7 +1774,7 @@ static void test_GlobalAlloc(void)
if
(
flags
==
GMEM_MOVEABLE
)
ok
(
size
==
10
,
"GlobalSize returned %Iu
\n
"
,
size
);
else
if
(
flags
)
{
todo_wine_if
((
flags
&
GMEM_
MOVEABLE
)
&&
!
(
flags
&
GMEM_MODIFY
))
todo_wine_if
((
flags
&
GMEM_
DISCARDABLE
)
&&
(
flags
&
(
GMEM_MODIFY
|
GMEM_MOVEABLE
|
GMEM_DISCARDABLE
))
!=
(
GMEM_MODIFY
|
GMEM_MOVEABLE
|
GMEM_DISCARDABLE
))
ok
(
size
==
12
,
"GlobalSize returned %Iu
\n
"
,
size
);
}
else
ok
(
size
==
12
||
broken
(
size
==
10
)
/* w8 */
,
"GlobalSize returned %Iu
\n
"
,
size
);
...
...
@@ -1917,10 +1917,7 @@ static void test_GlobalAlloc(void)
if
(
!
(
flags
&
GMEM_MODIFY
)
&&
(
flags
&
GMEM_DISCARDABLE
))
todo_wine
ok
(
!
tmp_mem
,
"GlobalReAlloc succeeded
\n
"
);
else
{
todo_wine_if
(
flags
&&
(
!
(
flags
&
GMEM_MOVEABLE
)
||
flags
==
(
GMEM_MODIFY
|
GMEM_MOVEABLE
)))
ok
(
tmp_mem
==
mem
,
"GlobalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
entry
=
*
mem_entry_from_HANDLE
(
mem
);
if
((
flags
&
GMEM_DISCARDABLE
)
&&
(
flags
&
GMEM_MODIFY
))
expect_entry
.
flags
|=
4
;
if
((
flags
&
GMEM_DISCARDABLE
)
||
(
flags
&
GMEM_MODIFY
))
...
...
@@ -1947,10 +1944,7 @@ static void test_GlobalAlloc(void)
if
(
!
(
flags
&
GMEM_MODIFY
)
&&
(
flags
&
GMEM_DISCARDABLE
))
todo_wine
ok
(
!
tmp_mem
,
"GlobalReAlloc succeeded
\n
"
);
else
{
todo_wine_if
(
flags
&&
(
!
(
flags
&
GMEM_MOVEABLE
)
||
flags
==
(
GMEM_MODIFY
|
GMEM_MOVEABLE
)))
ok
(
tmp_mem
==
mem
,
"GlobalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
entry
=
*
mem_entry_from_HANDLE
(
mem
);
if
((
flags
&
GMEM_DISCARDABLE
)
&&
(
flags
&
GMEM_MODIFY
))
expect_entry
.
flags
|=
4
;
ok
(
entry
.
ptr
==
expect_entry
.
ptr
,
"got ptr %p was %p
\n
"
,
entry
.
ptr
,
expect_entry
.
ptr
);
...
...
@@ -1976,10 +1970,7 @@ static void test_GlobalAlloc(void)
else
if
(
!
(
flags
&
GMEM_MODIFY
)
&&
(
flags
&
GMEM_DISCARDABLE
))
todo_wine
ok
(
!
tmp_mem
,
"GlobalReAlloc succeeded
\n
"
);
else
{
todo_wine_if
(
!
(
flags
&
GMEM_MOVEABLE
)
||
flags
==
(
GMEM_MODIFY
|
GMEM_MOVEABLE
))
ok
(
tmp_mem
==
mem
,
"GlobalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
entry
=
*
mem_entry_from_HANDLE
(
mem
);
if
(
flags
==
GMEM_MOVEABLE
)
{
...
...
@@ -2474,10 +2465,7 @@ static void test_LocalAlloc(void)
if
(
!
(
flags
&
LMEM_MODIFY
)
&&
((
flags
&
LMEM_DISCARDABLE
)
||
!
(
flags
&
LMEM_MOVEABLE
)))
todo_wine
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
else
{
todo_wine_if
((
!
(
flags
&
LMEM_MOVEABLE
)
||
flags
==
(
LMEM_MODIFY
|
LMEM_MOVEABLE
)))
ok
(
tmp_mem
==
mem
,
"LocalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
entry
=
*
mem_entry_from_HANDLE
(
mem
);
if
((
flags
&
LMEM_DISCARDABLE
)
&&
(
flags
&
LMEM_MODIFY
))
expect_entry
.
flags
|=
4
;
if
(
flags
==
LMEM_MOVEABLE
)
ok
(
entry
.
ptr
!=
expect_entry
.
ptr
,
"got unexpected ptr %p
\n
"
,
entry
.
ptr
);
...
...
@@ -2504,10 +2492,7 @@ static void test_LocalAlloc(void)
if
(
!
(
flags
&
LMEM_MODIFY
)
&&
(
flags
&
LMEM_DISCARDABLE
))
todo_wine
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
else
{
todo_wine_if
(
flags
&&
(
!
(
flags
&
LMEM_MOVEABLE
)
||
flags
==
(
LMEM_MODIFY
|
LMEM_MOVEABLE
)))
ok
(
tmp_mem
==
mem
,
"LocalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
entry
=
*
mem_entry_from_HANDLE
(
mem
);
if
((
flags
&
LMEM_DISCARDABLE
)
&&
(
flags
&
LMEM_MODIFY
))
expect_entry
.
flags
|=
4
;
ok
(
entry
.
ptr
==
expect_entry
.
ptr
,
"got ptr %p was %p
\n
"
,
entry
.
ptr
,
expect_entry
.
ptr
);
...
...
@@ -2533,10 +2518,7 @@ static void test_LocalAlloc(void)
tmp_mem
=
LocalReAlloc
(
mem
,
0
,
flags
);
if
(
flags
&
LMEM_MODIFY
)
{
todo_wine_if
(
!
(
flags
&
LMEM_MOVEABLE
)
||
(
flags
==
(
LMEM_MOVEABLE
|
LMEM_MODIFY
)))
ok
(
tmp_mem
==
mem
,
"LocalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
else
todo_wine
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
entry
=
*
mem_entry_from_HANDLE
(
mem
);
...
...
@@ -2564,10 +2546,7 @@ static void test_LocalAlloc(void)
if
(
!
(
flags
&
LMEM_MODIFY
)
&&
(
flags
&
LMEM_DISCARDABLE
))
todo_wine
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
else
{
todo_wine_if
(
flags
&&
(
!
(
flags
&
LMEM_MOVEABLE
)
||
flags
==
(
LMEM_MODIFY
|
LMEM_MOVEABLE
)))
ok
(
tmp_mem
==
mem
,
"LocalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
entry
=
*
mem_entry_from_HANDLE
(
mem
);
if
((
flags
&
LMEM_DISCARDABLE
)
&&
(
flags
&
LMEM_MODIFY
))
expect_entry
.
flags
|=
4
;
if
((
flags
&
LMEM_DISCARDABLE
)
||
(
flags
&
LMEM_MODIFY
))
...
...
@@ -2594,10 +2573,7 @@ static void test_LocalAlloc(void)
if
(
!
(
flags
&
LMEM_MODIFY
)
&&
(
flags
&
LMEM_DISCARDABLE
))
todo_wine
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
else
{
todo_wine_if
(
flags
&&
(
!
(
flags
&
LMEM_MOVEABLE
)
||
flags
==
(
LMEM_MODIFY
|
LMEM_MOVEABLE
)))
ok
(
tmp_mem
==
mem
,
"LocalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
entry
=
*
mem_entry_from_HANDLE
(
mem
);
if
((
flags
&
LMEM_DISCARDABLE
)
&&
(
flags
&
LMEM_MODIFY
))
expect_entry
.
flags
|=
4
;
ok
(
entry
.
ptr
==
expect_entry
.
ptr
,
"got ptr %p was %p
\n
"
,
entry
.
ptr
,
expect_entry
.
ptr
);
...
...
@@ -2623,10 +2599,7 @@ static void test_LocalAlloc(void)
else
if
(
!
(
flags
&
LMEM_MODIFY
)
&&
(
flags
&
LMEM_DISCARDABLE
))
todo_wine
ok
(
!
tmp_mem
,
"LocalReAlloc succeeded
\n
"
);
else
{
todo_wine_if
(
!
(
flags
&
LMEM_MOVEABLE
)
||
flags
==
(
LMEM_MODIFY
|
LMEM_MOVEABLE
))
ok
(
tmp_mem
==
mem
,
"LocalReAlloc returned %p, error %lu
\n
"
,
tmp_mem
,
GetLastError
()
);
}
entry
=
*
mem_entry_from_HANDLE
(
mem
);
if
(
flags
==
LMEM_MOVEABLE
)
{
...
...
dlls/kernelbase/memory.c
View file @
86d09091
...
...
@@ -1000,7 +1000,12 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL handle, SIZE_T size, UINT f
}
else
if
((
mem
=
unsafe_mem_from_HLOCAL
(
handle
)))
{
if
(
!
(
flags
&
LMEM_MODIFY
))
if
(
flags
&
LMEM_MODIFY
)
{
if
(
flags
&
LMEM_DISCARDABLE
)
mem
->
flags
|=
MEM_FLAG_DISCARDABLE
;
ret
=
handle
;
}
else
{
if
(
size
)
{
...
...
@@ -1025,12 +1030,6 @@ HLOCAL WINAPI DECLSPEC_HOTPATCH LocalReAlloc( HLOCAL handle, SIZE_T size, UINT f
ret
=
handle
;
}
}
else
if
(
flags
&
LMEM_DISCARDABLE
)
{
mem
->
flags
|=
MEM_FLAG_DISCARDABLE
;
ret
=
handle
;
}
else
SetLastError
(
ERROR_INVALID_PARAMETER
);
}
else
SetLastError
(
ERROR_INVALID_HANDLE
);
RtlUnlockHeap
(
heap
);
...
...
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