Module: wine Branch: refs/heads/master Commit: c79cf02fae38f26eb91c1f1e43b3950e523930ed URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=c79cf02fae38f26eb91c1f1e...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Jul 13 20:47:07 2006 +0200
ntdll: Make sure to not unmap anything from reserved areas when using NtFreeVirtualMemory with the MEM_SYSTEM flag.
---
dlls/ntdll/virtual.c | 3 ++- loader/kthread.c | 4 ++-- loader/pthread.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index cd0beab..2d4f6f3 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1386,7 +1386,8 @@ NTSTATUS WINAPI NtFreeVirtualMemory( HAN { /* return the values that the caller should use to unmap the area */ *addr_ptr = view->base; - *size_ptr = view->size; + if (!wine_mmap_is_in_reserved_area( view->base, view->size )) *size_ptr = view->size; + else *size_ptr = 0; /* make sure we don't munmap anything from a reserved area */ view->flags |= VFLAG_SYSTEM; delete_view( view ); } diff --git a/loader/kthread.c b/loader/kthread.c index a012aad..577311b 100644 --- a/loader/kthread.c +++ b/loader/kthread.c @@ -190,8 +190,8 @@ static void cleanup_thread( void *ptr ) /* copy the info structure since it is on the stack we will free */ struct wine_pthread_thread_info info = *(struct wine_pthread_thread_info *)ptr; wine_ldt_free_fs( info.teb_sel ); - munmap( info.stack_base, info.stack_size ); - munmap( info.teb_base, info.teb_size ); + if (info.stack_size) munmap( info.stack_base, info.stack_size ); + if (info.teb_size) munmap( info.teb_base, info.teb_size ); #ifdef HAVE__LWP_CREATE _lwp_exit(); #endif diff --git a/loader/pthread.c b/loader/pthread.c index b7487a0..a976c4f 100644 --- a/loader/pthread.c +++ b/loader/pthread.c @@ -159,7 +159,7 @@ #endif static void DECLSPEC_NORETURN exit_thread( struct wine_pthread_thread_info *info ) { wine_ldt_free_fs( info->teb_sel ); - munmap( info->teb_base, info->teb_size ); + if (info->teb_size) munmap( info->teb_base, info->teb_size ); pthread_exit( (void *)info->exit_status ); }