From 9fa0891acd0694a596cf8d3df18cd9615f409590 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sun, 11 Dec 2016 05:52:30 -0500 Subject: [PATCH] Fix: handle size 0 CTF fs streams MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- plugins/ctf/fs/data-stream.c | 9 --------- plugins/ctf/fs/fs.c | 6 ++++++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/plugins/ctf/fs/data-stream.c b/plugins/ctf/fs/data-stream.c index 36625097..ca5b47e8 100644 --- a/plugins/ctf/fs/data-stream.c +++ b/plugins/ctf/fs/data-stream.c @@ -120,15 +120,6 @@ enum bt_ctf_notif_iter_medium_status medop_request_bytes( goto end; } - /* Check if we need an initial memory map */ - if (!stream->mmap_addr) { - if (mmap_next(stream)) { - PERR("Cannot memory-map initial region of file \"%s\" (%p)\n", - stream->file->path->str, stream->file->fp); - goto error; - } - } - /* Check if we have at least one memory-mapped byte left */ if (remaining_mmap_bytes(stream) == 0) { /* Are we at the end of the file? */ diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index 3a60b0d5..71ae52b0 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -554,6 +554,12 @@ int open_trace_streams(struct ctf_fs_component *ctf_fs, goto error; } + if (file->size == 0) { + /* Skip empty stream. */ + ctf_fs_file_destroy(file); + continue; + } + /* Create a private stream; file ownership is passed to it. */ stream = ctf_fs_stream_create(ctf_fs, file); if (!stream) { -- 2.34.1