Fix memory leak in pthread_getattr_np

* thread.cc (pthread_getattr_np): Fix memory leak, remove usage of
	malloc for small local buffer.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2015-10-21 12:46:32 +02:00
parent 713161b28b
commit c0345822e5
3 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2015-10-21 Corinna Vinschen <corinna@vinschen.de>
* thread.cc (pthread_getattr_np): Fix memory leak, remove usage of
malloc for small local buffer.
2015-10-21 Corinna Vinschen <corinna@vinschen.de>
* path.cc (symlink_info::check_reparse_point): Don't generate an EIO

View File

@ -39,3 +39,5 @@ Bug Fixes
- Fix EIO error accessing certain (OS X SMB?) drives
Addresses: https://cygwin.com/ml/cygwin/2015-09/msg00229.html
- Fix memory leak in calls to pthread_getattr_np.

View File

@ -2485,8 +2485,7 @@ pthread::resume (pthread_t *thread)
extern "C" int
pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
{
const size_t sizeof_tbi = sizeof (THREAD_BASIC_INFORMATION);
PTHREAD_BASIC_INFORMATION tbi;
THREAD_BASIC_INFORMATION tbi;
NTSTATUS status;
if (!pthread::is_good_object (&thread))
@ -2506,13 +2505,12 @@ pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
(*attr)->schedparam = thread->attr.schedparam;
(*attr)->guardsize = thread->attr.guardsize;
tbi = (PTHREAD_BASIC_INFORMATION) malloc (sizeof_tbi);
status = NtQueryInformationThread (thread->win32_obj_id,
ThreadBasicInformation,
tbi, sizeof_tbi, NULL);
&tbi, sizeof (tbi), NULL);
if (NT_SUCCESS (status))
{
PTEB teb = (PTEB) tbi->TebBaseAddress;
PTEB teb = (PTEB) tbi.TebBaseAddress;
/* stackaddr holds the uppermost stack address. See the comments
in pthread_attr_setstack and pthread_attr_setstackaddr for a
description. */