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
08f4b6ee
Commit
08f4b6ee
authored
Apr 16, 2020
by
Nikolay Sivov
Committed by
Alexandre Julliard
Apr 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Fix IMalloc::DidAlloc() return value to reflect block validity.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c56e5695
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
22 deletions
+58
-22
ifs.c
dlls/ole32/ifs.c
+37
-22
compobj.c
dlls/ole32/tests/compobj.c
+21
-0
No files found.
dlls/ole32/ifs.c
View file @
08f4b6ee
...
...
@@ -114,6 +114,20 @@ static BOOL AddMemoryLocation(LPVOID * pMem)
return
TRUE
;
}
static
void
**
mallocspy_is_allocation_spyed
(
const
void
*
mem
)
{
void
**
current
=
Malloc32
.
SpyedBlocks
;
while
(
*
current
!=
mem
)
{
current
++
;
if
(
current
>=
Malloc32
.
SpyedBlocks
+
Malloc32
.
SpyedBlockTableLength
)
return
NULL
;
}
return
current
;
}
static
BOOL
RemoveMemoryLocation
(
LPCVOID
pMem
)
{
LPVOID
*
Current
;
...
...
@@ -122,14 +136,8 @@ static BOOL RemoveMemoryLocation(LPCVOID pMem)
if
(
!
Malloc32
.
SpyedBlockTableLength
&&
!
SetSpyedBlockTableLength
(
0x1000
))
return
FALSE
;
Current
=
Malloc32
.
SpyedBlocks
;
/* find the location */
while
(
*
Current
!=
pMem
)
{
Current
++
;
if
(
Current
>=
Malloc32
.
SpyedBlocks
+
Malloc32
.
SpyedBlockTableLength
)
return
FALSE
;
/* not found */
}
if
(
!
(
Current
=
mallocspy_is_allocation_spyed
(
pMem
)))
return
FALSE
;
/* location found */
Malloc32
.
SpyedAllocationsLeft
--
;
...
...
@@ -313,25 +321,32 @@ static SIZE_T WINAPI IMalloc_fnGetSize(IMalloc *iface, void *pv)
/******************************************************************************
* IMalloc32_DidAlloc [VTABLE]
*/
static
INT
WINAPI
IMalloc_fnDidAlloc
(
IMalloc
*
iface
,
void
*
pv
)
static
INT
WINAPI
IMalloc_fnDidAlloc
(
IMalloc
*
iface
,
void
*
mem
)
{
BOOL
fSpyed
=
FALSE
;
int
didA
lloc
;
BOOL
spyed_block
=
FALSE
;
int
did_a
lloc
;
TRACE
(
"(%p)
\n
"
,
pv
);
TRACE
(
"(%p)
\n
"
,
mem
);
if
(
Malloc32
.
pSpy
)
{
EnterCriticalSection
(
&
IMalloc32_SpyCS
);
pv
=
IMallocSpy_PreDidAlloc
(
Malloc32
.
pSpy
,
pv
,
fSpyed
);
}
if
(
!
mem
)
return
-
1
;
if
(
Malloc32
.
pSpy
)
{
EnterCriticalSection
(
&
IMalloc32_SpyCS
);
spyed_block
=
!!
mallocspy_is_allocation_spyed
(
mem
);
mem
=
IMallocSpy_PreDidAlloc
(
Malloc32
.
pSpy
,
mem
,
spyed_block
);
}
didAlloc
=
-
1
;
did_alloc
=
HeapValidate
(
GetProcessHeap
(),
0
,
mem
)
;
if
(
Malloc32
.
pSpy
)
{
didAlloc
=
IMallocSpy_PostDidAlloc
(
Malloc32
.
pSpy
,
pv
,
fSpyed
,
didAlloc
);
LeaveCriticalSection
(
&
IMalloc32_SpyCS
);
}
return
didAlloc
;
if
(
Malloc32
.
pSpy
)
{
did_alloc
=
IMallocSpy_PostDidAlloc
(
Malloc32
.
pSpy
,
mem
,
spyed_block
,
did_alloc
);
LeaveCriticalSection
(
&
IMalloc32_SpyCS
);
}
return
did_alloc
;
}
/******************************************************************************
...
...
dlls/ole32/tests/compobj.c
View file @
08f4b6ee
...
...
@@ -3069,6 +3069,8 @@ static void test_CoGetMalloc(void)
{
IMalloc
*
imalloc
;
HRESULT
hr
;
char
*
ptr
;
int
ret
;
if
(
0
)
/* crashes on native */
hr
=
CoGetMalloc
(
0
,
NULL
);
...
...
@@ -3102,6 +3104,25 @@ static void test_CoGetMalloc(void)
hr
=
CoGetMalloc
(
MEMCTX_TASK
,
&
imalloc
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
imalloc
!=
NULL
,
"got %p
\n
"
,
imalloc
);
/* DidAlloc() */
ptr
=
IMalloc_Alloc
(
imalloc
,
16
);
ok
(
!!
ptr
,
"Failed to allocate block.
\n
"
);
ret
=
IMalloc_DidAlloc
(
imalloc
,
ptr
);
ok
(
ret
==
1
,
"Unexpected return value %d.
\n
"
,
ret
);
ret
=
IMalloc_DidAlloc
(
imalloc
,
NULL
);
ok
(
ret
==
-
1
,
"Unexpected return value %d.
\n
"
,
ret
);
ret
=
IMalloc_DidAlloc
(
imalloc
,
(
void
*
)
0x1
);
ok
(
ret
==
0
,
"Unexpected return value %d.
\n
"
,
ret
);
ret
=
IMalloc_DidAlloc
(
imalloc
,
ptr
+
4
);
ok
(
ret
==
0
,
"Unexpected return value %d.
\n
"
,
ret
);
IMalloc_Free
(
imalloc
,
ptr
);
IMalloc_Release
(
imalloc
);
}
...
...
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