Fix: write index only if fd is valid
authorDavid Goulet <dgoulet@efficios.com>
Tue, 11 Feb 2014 19:13:01 +0000 (14:13 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 11 Feb 2014 19:58:46 +0000 (14:58 -0500)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/index/index.c

index 54689677ee4a2f3dd3c56a6f06236115f659ead6..58918caaa7dc6dfd790c15d9ced857ad2ecf7c4e 100644 (file)
@@ -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;
 }
 
This page took 0.026217 seconds and 4 git commands to generate.