From d0d8b753505b467717cf7916adb9bc9336bd9e46 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 19 Mar 2012 17:34:23 +0000 Subject: [PATCH] * thread.cc (cancelable_wait): Don't malloc tbi, just make it a struct on the stack to avoid memory leak. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/thread.cc | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3c25957d1..8430abdae 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2012-03-19 Corinna Vinschen + + * thread.cc (cancelable_wait): Don't malloc tbi, just make it a struct + on the stack to avoid memory leak. + 2012-03-19 Christopher Faylor * pinfo.cc (pinfo::wait): Handle case where prefork was not called diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 513b860d1..af0d6afc7 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -982,15 +982,14 @@ cancelable_wait (HANDLE object, PLARGE_INTEGER timeout, if (timeout) { - const size_t sizeof_tbi = sizeof (TIMER_BASIC_INFORMATION); - PTIMER_BASIC_INFORMATION tbi = (PTIMER_BASIC_INFORMATION) malloc (sizeof_tbi); + TIMER_BASIC_INFORMATION tbi; - NtQueryTimer (_my_tls.locals.cw_timer, TimerBasicInformation, tbi, - sizeof_tbi, NULL); + NtQueryTimer (_my_tls.locals.cw_timer, TimerBasicInformation, &tbi, + sizeof tbi, NULL); /* if timer expired, TimeRemaining is negative and represents the system uptime when signalled */ if (timeout->QuadPart < 0LL) - timeout->QuadPart = tbi->SignalState ? 0LL : tbi->TimeRemaining.QuadPart; + timeout->QuadPart = tbi.SignalState ? 0LL : tbi.TimeRemaining.QuadPart; NtCancelTimer (_my_tls.locals.cw_timer, NULL); }