Fix: don't close the metadata FD if a FP is passed
authorJulien Desfossez <jdesfossez@efficios.com>
Fri, 17 Aug 2012 11:57:53 +0000 (07:57 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 17 Aug 2012 11:57:53 +0000 (07:57 -0400)
In ctf_open_trace_metadata_read if the metadata_fp is passed we must
not close the metadata_stream->pos.fd which is zero in this case.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c

index 69600d1f8ca1b6e21e858eee326a2c236e0b2165..c369d8d36487ae79980a1caa747a79a4f2f916ec 100644 (file)
@@ -1011,6 +1011,7 @@ int ctf_open_trace_metadata_read(struct ctf_trace *td,
 
        if (metadata_fp) {
                fp = metadata_fp;
+               metadata_stream->pos.fd = -1;
        } else {
                td->metadata = &metadata_stream->parent;
                metadata_stream->pos.fd = openat(td->dirfd, "metadata", O_RDONLY);
@@ -1090,7 +1091,8 @@ end_packet_read:
                fclose(fp);
        free(buf);
 end_stream:
-       close(metadata_stream->pos.fd);
+       if (metadata_stream->pos.fd >= 0)
+               close(metadata_stream->pos.fd);
        if (ret)
                g_free(metadata_stream);
        return ret;
This page took 0.033689 seconds and 4 git commands to generate.