diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2020-11-18 20:27:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 14:27:56 -0500 |
commit | fc2c1a2341c0bedfca3bded96ac7dce8b3575b53 (patch) | |
tree | c7369c8a4bddb9ec5b725e9aef4d606a44127af4 | |
parent | 4ddc292774be827a297449e2d5ef4047c85de7ca (diff) | |
download | libuv-fc2c1a2341c0bedfca3bded96ac7dce8b3575b53.tar.gz libuv-fc2c1a2341c0bedfca3bded96ac7dce8b3575b53.zip |
unix,win: initialize timer `timeout` field
With the addition of `uv_timer_get_due_in()` it's observable with tools like
valgrind that the `timer->timeout` field isn't initialized until the timer
is started.
Fixes the following valgrind warning when running the `timer_init` test:
==325215== Conditional jump or move depends on uninitialised value(s)
==325215== at 0x1B0131: uv_timer_get_due_in (timer.c:134)
==325215== by 0x19AF09: run_test_timer_init (test-timer.c:164)
==325215== by 0x119FF1: run_test_part (runner.c:376)
==325215== by 0x11875D: main (run-tests.c:68)
==325215==
==325215== Conditional jump or move depends on uninitialised value(s)
==325215== at 0x19AF1F: run_test_timer_init (test-timer.c:164)
==325215== by 0x119FF1: run_test_part (runner.c:376)
==325215== by 0x11875D: main (run-tests.c:68)
Fixes: https://github.com/libuv/libuv/issues/3020
PR-URL: https://github.com/libuv/libuv/pull/3038
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
-rw-r--r-- | src/timer.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/timer.c b/src/timer.c index 1bea2a8b..bc680e71 100644 --- a/src/timer.c +++ b/src/timer.c @@ -58,6 +58,7 @@ static int timer_less_than(const struct heap_node* ha, int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) { uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER); handle->timer_cb = NULL; + handle->timeout = 0; handle->repeat = 0; return 0; } |