* thread.cc (cancelable_wait): Don't malloc tbi, just make it a struct

on the stack to avoid memory leak.
This commit is contained in:
Corinna Vinschen 2012-03-19 17:34:23 +00:00
parent d9492ab8d2
commit d0d8b75350
2 changed files with 9 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2012-03-19 Corinna Vinschen <corinna@vinschen.de>
* 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 <me.cygwin2012@cgf.cx>
* pinfo.cc (pinfo::wait): Handle case where prefork was not called

View File

@ -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);
}