From fb3650918c0ec6050e469157109d05158841b125 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 20 Dec 2017 11:34:18 +0100 Subject: [PATCH] test_rtt: fix segfault when case not started --- lib/nodes/test_rtt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/nodes/test_rtt.c b/lib/nodes/test_rtt.c index e3747cb62..c55b4afeb 100644 --- a/lib/nodes/test_rtt.c +++ b/lib/nodes/test_rtt.c @@ -272,7 +272,7 @@ int test_rtt_stop(struct node *n) int ret; struct test_rtt *t = (struct test_rtt *) n->_vd; - if (t->counter != -1) { + if (t->counter >= 0) { ret = test_rtt_case_stop(t, t->current); if (ret) return ret; @@ -289,7 +289,7 @@ int test_rtt_read(struct node *n, struct sample *smps[], unsigned cnt) struct test_rtt *t = (struct test_rtt *) n->_vd; if (t->counter == -1) { - if (t->current == -1) { + if (t->current < 0) { t->current = 0; } else { @@ -355,6 +355,10 @@ int test_rtt_read(struct node *n, struct sample *smps[], unsigned cnt) int test_rtt_write(struct node *n, struct sample *smps[], unsigned cnt) { struct test_rtt *t = (struct test_rtt *) n->_vd; + + if (t->current < 0) + return 0; + struct test_rtt_case *c = (struct test_rtt_case *) list_at(&t->cases, t->current); int i;