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
55a14edd
Commit
55a14edd
authored
Nov 20, 2001
by
Andreas Mohr
Committed by
Alexandre Julliard
Nov 20, 2001
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use exception handler for GlobalUnlock, GlobalFree.
parent
ae1c12c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
50 deletions
+69
-50
global.c
memory/global.c
+69
-50
No files found.
memory/global.c
View file @
55a14edd
...
...
@@ -1103,31 +1103,39 @@ LPVOID WINAPI GlobalLock(
BOOL
WINAPI
GlobalUnlock
(
HGLOBAL
hmem
/* [in] Handle of global memory object */
)
{
PGLOBAL32_INTERN
pintern
;
BOOL
locked
;
PGLOBAL32_INTERN
pintern
;
BOOL
locked
;
if
(
ISPOINTER
(
hmem
))
return
FALSE
;
if
(
ISPOINTER
(
hmem
))
return
FALSE
;
/* HeapLock(GetProcessHeap()); */
pintern
=
HANDLE_TO_INTERN
(
hmem
);
if
(
pintern
->
Magic
==
MAGIC_GLOBAL_USED
)
{
if
((
pintern
->
LockCount
<
GLOBAL_LOCK_MAX
)
&&
(
pintern
->
LockCount
>
0
))
pintern
->
LockCount
--
;
__TRY
{
/* HeapLock(GetProcessHeap()); */
pintern
=
HANDLE_TO_INTERN
(
hmem
);
if
(
pintern
->
Magic
==
MAGIC_GLOBAL_USED
)
{
if
((
pintern
->
LockCount
<
GLOBAL_LOCK_MAX
)
&&
(
pintern
->
LockCount
>
0
))
pintern
->
LockCount
--
;
locked
=
(
pintern
->
LockCount
!=
0
);
if
(
!
locked
)
SetLastError
(
NO_ERROR
);
}
else
{
WARN
(
"invalid handle
\n
"
);
SetLastError
(
ERROR_INVALID_HANDLE
);
locked
=
FALSE
;
}
/* HeapUnlock(GetProcessHeap()); */
return
locked
;
locked
=
(
pintern
->
LockCount
!=
0
);
if
(
!
locked
)
SetLastError
(
NO_ERROR
);
}
else
{
WARN
(
"invalid handle
\n
"
);
SetLastError
(
ERROR_INVALID_HANDLE
);
locked
=
FALSE
;
}
/* HeapUnlock(GetProcessHeap()); */
}
__EXCEPT
(
page_fault
)
{
ERR
(
"page fault occurred ! Caused by bug ?
\n
"
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
__ENDTRY
return
locked
;
}
...
...
@@ -1305,35 +1313,46 @@ HGLOBAL WINAPI GlobalReAlloc(
HGLOBAL
WINAPI
GlobalFree
(
HGLOBAL
hmem
/* [in] Handle of global memory object */
)
{
PGLOBAL32_INTERN
pintern
;
HGLOBAL
hreturned
=
0
;
PGLOBAL32_INTERN
pintern
;
HGLOBAL
hreturned
;
if
(
ISPOINTER
(
hmem
))
/* POINTER */
{
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
(
LPVOID
)
hmem
))
hmem
=
0
;
}
else
/* HANDLE */
{
/* HeapLock(heap); */
pintern
=
HANDLE_TO_INTERN
(
hmem
);
if
(
pintern
->
Magic
==
MAGIC_GLOBAL_USED
)
{
/* WIN98 does not make this test. That is you can free a */
/* block you have not unlocked. Go figure!! */
/* if(pintern->LockCount!=0) */
/* SetLastError(ERROR_INVALID_HANDLE); */
if
(
pintern
->
Pointer
)
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
(
char
*
)(
pintern
->
Pointer
)
-
sizeof
(
HGLOBAL
)))
hreturned
=
hmem
;
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
pintern
))
hreturned
=
hmem
;
}
/* HeapUnlock(heap); */
}
return
hreturned
;
__TRY
{
hreturned
=
0
;
if
(
ISPOINTER
(
hmem
))
/* POINTER */
{
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
(
LPVOID
)
hmem
))
hmem
=
0
;
}
else
/* HANDLE */
{
/* HeapLock(heap); */
pintern
=
HANDLE_TO_INTERN
(
hmem
);
if
(
pintern
->
Magic
==
MAGIC_GLOBAL_USED
)
{
/* WIN98 does not make this test. That is you can free a */
/* block you have not unlocked. Go figure!! */
/* if(pintern->LockCount!=0) */
/* SetLastError(ERROR_INVALID_HANDLE); */
if
(
pintern
->
Pointer
)
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
(
char
*
)(
pintern
->
Pointer
)
-
sizeof
(
HGLOBAL
)))
hreturned
=
hmem
;
if
(
!
HeapFree
(
GetProcessHeap
(),
0
,
pintern
))
hreturned
=
hmem
;
}
/* HeapUnlock(heap); */
}
}
__EXCEPT
(
page_fault
)
{
ERR
(
"page fault occurred ! Caused by bug ?
\n
"
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
hmem
;
}
__ENDTRY
return
hreturned
;
}
...
...
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