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
ce450253
Commit
ce450253
authored
Nov 25, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Nov 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Return the old data size from heap_reallocate.
parent
4334c5b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
heap.c
dlls/ntdll/heap.c
+13
-13
No files found.
dlls/ntdll/heap.c
View file @
ce450253
...
...
@@ -1623,11 +1623,11 @@ BOOLEAN WINAPI DECLSPEC_HOTPATCH RtlFreeHeap( HANDLE handle, ULONG flags, void *
}
static
NTSTATUS
heap_reallocate
(
struct
heap
*
heap
,
ULONG
flags
,
struct
block
*
block
,
SIZE_T
block_size
,
SIZE_T
size
,
void
**
ret
)
static
NTSTATUS
heap_reallocate
(
struct
heap
*
heap
,
ULONG
flags
,
struct
block
*
block
,
SIZE_T
block_size
,
SIZE_T
size
,
SIZE_T
*
old_
size
,
void
**
ret
)
{
SUBHEAP
*
subheap
=
block_get_subheap
(
heap
,
block
);
SIZE_T
old_block_size
,
old_size
;
SIZE_T
old_block_size
;
struct
entry
*
entry
;
struct
block
*
next
;
NTSTATUS
status
;
...
...
@@ -1636,7 +1636,7 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b
{
ARENA_LARGE
*
large
=
CONTAINING_RECORD
(
block
,
ARENA_LARGE
,
block
);
old_block_size
=
large
->
block_size
;
old_size
=
large
->
data_size
;
*
old_size
=
large
->
data_size
;
if
(
old_block_size
-
sizeof
(
*
block
)
<
size
)
{
...
...
@@ -1646,8 +1646,8 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b
}
/* FIXME: we could remap zero-pages instead */
valgrind_notify_resize
(
block
+
1
,
old_size
,
size
);
initialize_block
(
block
,
old_size
,
size
,
flags
);
valgrind_notify_resize
(
block
+
1
,
*
old_size
,
size
);
initialize_block
(
block
,
*
old_size
,
size
,
flags
);
large
->
data_size
=
size
;
valgrind_make_noaccess
(
(
char
*
)
block
+
sizeof
(
*
block
)
+
large
->
data_size
,
...
...
@@ -1660,7 +1660,7 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b
/* Check if we need to grow the block */
old_block_size
=
block_get_size
(
block
);
old_size
=
old_block_size
-
block_get_overhead
(
block
);
*
old_size
=
old_block_size
-
block_get_overhead
(
block
);
if
(
block_size
>
old_block_size
)
{
...
...
@@ -1671,8 +1671,8 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b
if
(
flags
&
HEAP_REALLOC_IN_PLACE_ONLY
)
return
STATUS_NO_MEMORY
;
if
((
status
=
heap_allocate
(
heap
,
flags
&
~
HEAP_ZERO_MEMORY
,
block_size
,
size
,
ret
)))
return
status
;
valgrind_notify_alloc
(
*
ret
,
size
,
0
);
memcpy
(
*
ret
,
block
+
1
,
old_size
);
if
(
flags
&
HEAP_ZERO_MEMORY
)
memset
(
(
char
*
)
*
ret
+
old_size
,
0
,
size
-
old_size
);
memcpy
(
*
ret
,
block
+
1
,
*
old_size
);
if
(
flags
&
HEAP_ZERO_MEMORY
)
memset
(
(
char
*
)
*
ret
+
*
old_size
,
0
,
size
-
*
old_size
);
valgrind_notify_free
(
block
+
1
);
free_used_block
(
heap
,
flags
,
block
);
return
STATUS_SUCCESS
;
...
...
@@ -1687,11 +1687,11 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b
old_block_size
+=
block_get_size
(
next
);
}
valgrind_notify_resize
(
block
+
1
,
old_size
,
size
);
valgrind_notify_resize
(
block
+
1
,
*
old_size
,
size
);
block_set_flags
(
block
,
BLOCK_FLAG_USER_MASK
&
~
BLOCK_FLAG_USER_INFO
,
BLOCK_USER_FLAGS
(
flags
)
);
shrink_used_block
(
heap
,
flags
,
block
,
old_block_size
,
block_size
,
size
);
initialize_block
(
block
,
old_size
,
size
,
flags
);
initialize_block
(
block
,
*
old_size
,
size
,
flags
);
mark_block_tail
(
block
,
flags
);
*
ret
=
block
+
1
;
...
...
@@ -1703,9 +1703,9 @@ static NTSTATUS heap_reallocate( struct heap *heap, ULONG flags, struct block *b
*/
void
*
WINAPI
RtlReAllocateHeap
(
HANDLE
handle
,
ULONG
flags
,
void
*
ptr
,
SIZE_T
size
)
{
SIZE_T
block_size
,
old_size
;
struct
block
*
block
;
struct
heap
*
heap
;
SIZE_T
block_size
;
ULONG
heap_flags
;
void
*
ret
=
NULL
;
NTSTATUS
status
;
...
...
@@ -1721,7 +1721,7 @@ void *WINAPI RtlReAllocateHeap( HANDLE handle, ULONG flags, void *ptr, SIZE_T si
else
{
heap_lock
(
heap
,
heap_flags
);
status
=
heap_reallocate
(
heap
,
heap_flags
,
block
,
block_size
,
size
,
&
ret
);
status
=
heap_reallocate
(
heap
,
heap_flags
,
block
,
block_size
,
size
,
&
old_size
,
&
ret
);
heap_unlock
(
heap
,
heap_flags
);
}
...
...
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