summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-03-06 23:08:35 +0100
committerJo-Philipp Wich <jo@mein.io>2022-03-06 23:24:13 +0100
commit0e859748a4e00cfad3bc50e386a06622066ee994 (patch)
tree80cf6cef4a3530876156c02a1685342736853f15
parent05bd7edd7a101aa09a54371aa34bc22646b75bee (diff)
uloop: clear errno before integer conversion attempts
In some cases, errno contains stale values from prior function invocations which might lead to random failures in uc_uloop_run(), uc_uloop_timer_set() and uc_uloop_timer(). Solve this issue by explicitly initializing errno to 0. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--lib/uloop.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/uloop.c b/lib/uloop.c
index 8b5adff..bc57336 100644
--- a/lib/uloop.c
+++ b/lib/uloop.c
@@ -111,6 +111,7 @@ uc_uloop_run(uc_vm_t *vm, size_t nargs)
uc_value_t *timeout = uc_fn_arg(0);
int t, rv;
+ errno = 0;
t = timeout ? (int)ucv_int64_get(timeout) : -1;
if (errno)
@@ -182,6 +183,7 @@ uc_uloop_timer_set(uc_vm_t *vm, size_t nargs)
if (!timer || !*timer)
err_return(EINVAL);
+ errno = 0;
t = timeout ? (int)ucv_int64_get(timeout) : -1;
if (errno)
@@ -243,6 +245,7 @@ uc_uloop_timer(uc_vm_t *vm, size_t nargs)
uc_value_t *res;
int t;
+ errno = 0;
t = timeout ? ucv_int64_get(timeout) : -1;
if (errno)