From 05f1df32a7453452765b0a46fb723047815ba2ef Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Wed, 10 Apr 2019 16:11:30 -0400 Subject: [PATCH] Fix: out_fd can be uninitialized. If out_fd is uninitialized return success. This happens for snapshot stream for example. Signed-off-by: Jonathan Rajotte --- src/common/consumer/consumer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index d46fc30a9..5a87e1896 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -3886,6 +3886,11 @@ int consumer_clear_stream_files(struct lttng_consumer_stream *stream) return LTTCOMM_CONSUMERD_SUCCESS; } + /* Stream might not have out_fd set. Snapshot stream for example. */ + if (stream->out_fd < 0) { + return LTTCOMM_CONSUMERD_SUCCESS; + } + ret = close(stream->out_fd); if (ret < 0) { PERROR("Closing tracefile"); -- 2.34.1