From: David Goulet Date: Tue, 11 Feb 2014 19:13:01 +0000 (-0500) Subject: Fix: write index only if fd is valid X-Git-Tag: v2.4.0-rc5~21 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2271a0b2342c6c45fd733fd995524313ddcb5733;p=lttng-tools.git Fix: write index only if fd is valid Signed-off-by: David Goulet --- diff --git a/src/common/index/index.c b/src/common/index/index.c index 54689677e..58918caaa 100644 --- a/src/common/index/index.c +++ b/src/common/index/index.c @@ -100,14 +100,19 @@ ssize_t index_write(int fd, struct ctf_packet_index *index, size_t len) { ssize_t ret; - assert(fd >= 0); assert(index); + if (fd < 0) { + ret = -EINVAL; + goto error; + } + ret = lttng_write(fd, index, len); if (ret < len) { PERROR("writing index file"); } +error: return ret; }