From: Jérémie Galarneau Date: Sat, 27 May 2017 19:10:37 +0000 (-0400) Subject: Fix: use of uninitialized value in visit_*_decl_entry X-Git-Tag: v2.0.0-pre1~147 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=5eae0c3c075678aab5c410e960d544ed102087fc Fix: use of uninitialized value in visit_*_decl_entry Signed-off-by: Jérémie Galarneau --- diff --git a/plugins/ctf/common/metadata/visitor-generate-ir.c b/plugins/ctf/common/metadata/visitor-generate-ir.c index b367e686..badbf995 100644 --- a/plugins/ctf/common/metadata/visitor-generate-ir.c +++ b/plugins/ctf/common/metadata/visitor-generate-ir.c @@ -3037,7 +3037,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = get_unary_unsigned(&node->u.ctf_expression.right, (uint64_t *) &id); - if (ret || id < 0) { + /* Only read "id" if get_unary_unsigned() succeeded. */ + if (ret || (!ret && id < 0)) { _PERROR("%s", "unexpected unary expression for event declaration's \"id\" attribute"); ret = -EINVAL; goto error; @@ -3061,7 +3062,11 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = get_unary_unsigned(&node->u.ctf_expression.right, (uint64_t *) stream_id); - if (ret || *stream_id < 0) { + /* + * Only read "stream_id" if get_unary_unsigned() + * succeeded. + */ + if (ret || (!ret && *stream_id < 0)) { _PERROR("%s", "unexpected unary expression for event declaration's \"stream_id\" attribute"); ret = -EINVAL; goto error; @@ -3575,7 +3580,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node, ret = get_unary_unsigned(&node->u.ctf_expression.right, (uint64_t *) &id); - if (ret || id < 0) { + /* Only read "id" if get_unary_unsigned() succeeded. */ + if (ret || (!ret && id < 0)) { _PERROR("%s", "unexpected unary expression for stream declaration's \"id\" attribute"); ret = -EINVAL; goto error;