1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-09 23:28:06 -05:00

Fix uninitialised variable in two Windows event loops.

If (Msg)WaitForMultipleObjects returns WAIT_TIMEOUT, we expect 'next'
to have been initialised. This can occur without having called
run_timers(), if a toplevel callback was pending, so we can't expect
run_timers to have reliably initialised 'next'.

I'm not actually convinced this could have come up in either of the
affected programs (Windows PSFTP and Plink), due to the list of things
toplevel callbacks are currently used for, but it certainly wants
fixing anyway for the future.

Spotted by Coverity.
This commit is contained in:
Simon Tatham 2014-11-22 10:18:16 +00:00
parent 068b67d2f6
commit b6c2346173
2 changed files with 6 additions and 0 deletions

View File

@ -661,6 +661,7 @@ int main(int argc, char **argv)
if (toplevel_callback_pending()) {
ticks = 0;
next = now;
} else if (run_timers(now, &next)) {
then = now;
now = GETTICKCOUNT();
@ -670,6 +671,8 @@ int main(int argc, char **argv)
ticks = next - now;
} else {
ticks = INFINITE;
/* no need to initialise next here because we can never
* get WAIT_TIMEOUT */
}
handles = handle_get_events(&nhandles);

View File

@ -495,6 +495,7 @@ int do_eventsel_loop(HANDLE other_event)
if (toplevel_callback_pending()) {
ticks = 0;
next = now;
} else if (run_timers(now, &next)) {
then = now;
now = GETTICKCOUNT();
@ -504,6 +505,8 @@ int do_eventsel_loop(HANDLE other_event)
ticks = next - now;
} else {
ticks = INFINITE;
/* no need to initialise next here because we can never get
* WAIT_TIMEOUT */
}
handles = handle_get_events(&nhandles);