Commit 5d12f637 authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Avoid getting the heap lock inside an exception handler block.

In case of a caught exception the lock is not released. Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent cf9f1859
...@@ -557,7 +557,7 @@ HGLOBAL WINAPI GlobalHandle( ...@@ -557,7 +557,7 @@ HGLOBAL WINAPI GlobalHandle(
/* GlobalAlloc with GMEM_MOVEABLE then magic test in HeapValidate */ /* GlobalAlloc with GMEM_MOVEABLE then magic test in HeapValidate */
/* will fail. */ /* will fail. */
if (ISPOINTER(pmem)) { if (ISPOINTER(pmem)) {
if (HeapValidate( GetProcessHeap(), 0, pmem )) { if (HeapValidate( GetProcessHeap(), HEAP_NO_SERIALIZE, pmem )) {
handle = (HGLOBAL)pmem; /* valid fixed block */ handle = (HGLOBAL)pmem; /* valid fixed block */
break; break;
} }
...@@ -569,8 +569,8 @@ HGLOBAL WINAPI GlobalHandle( ...@@ -569,8 +569,8 @@ HGLOBAL WINAPI GlobalHandle(
maybe_intern = HANDLE_TO_INTERN( handle ); maybe_intern = HANDLE_TO_INTERN( handle );
if (maybe_intern->Magic == MAGIC_GLOBAL_USED) { if (maybe_intern->Magic == MAGIC_GLOBAL_USED) {
test = maybe_intern->Pointer; test = maybe_intern->Pointer;
if (HeapValidate( GetProcessHeap(), 0, (const char *)test - HGLOBAL_STORAGE ) && /* obj(-handle) valid arena? */ if (HeapValidate( GetProcessHeap(), HEAP_NO_SERIALIZE, (const char *)test - HGLOBAL_STORAGE ) && /* obj(-handle) valid arena? */
HeapValidate( GetProcessHeap(), 0, maybe_intern )) /* intern valid arena? */ HeapValidate( GetProcessHeap(), HEAP_NO_SERIALIZE, maybe_intern )) /* intern valid arena? */
break; /* valid moveable block */ break; /* valid moveable block */
} }
handle = 0; handle = 0;
...@@ -749,7 +749,7 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem) ...@@ -749,7 +749,7 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
hreturned = 0; hreturned = 0;
if(ISPOINTER(hmem)) /* POINTER */ if(ISPOINTER(hmem)) /* POINTER */
{ {
if(!HeapFree(GetProcessHeap(), 0, hmem)) if(!HeapFree(GetProcessHeap(), HEAP_NO_SERIALIZE, hmem))
{ {
SetLastError(ERROR_INVALID_HANDLE); SetLastError(ERROR_INVALID_HANDLE);
hreturned = hmem; hreturned = hmem;
...@@ -769,9 +769,9 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem) ...@@ -769,9 +769,9 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
/* SetLastError(ERROR_INVALID_HANDLE); */ /* SetLastError(ERROR_INVALID_HANDLE); */
if(pintern->Pointer) if(pintern->Pointer)
if(!HeapFree(GetProcessHeap(), 0, (char *)(pintern->Pointer)-HGLOBAL_STORAGE)) if(!HeapFree(GetProcessHeap(), HEAP_NO_SERIALIZE, (char *)(pintern->Pointer)-HGLOBAL_STORAGE))
hreturned=hmem; hreturned=hmem;
if(!HeapFree(GetProcessHeap(), 0, pintern)) if(!HeapFree(GetProcessHeap(), HEAP_NO_SERIALIZE, pintern))
hreturned=hmem; hreturned=hmem;
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment