From 3abe83c77fdaadea8528e7787bafe1ed6c16a1ac Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 15 Sep 2011 13:05:41 -0400 Subject: [PATCH] Fix support for empty streams Signed-off-by: Mathieu Desnoyers --- formats/ctf/ctf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index f9f9e47f..27c03cfa 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -127,8 +127,16 @@ int ctf_read_event(struct stream_pos *ppos, struct ctf_stream *stream) uint64_t id = 0; int ret; + /* We need to check for EOF here for empty files. */ + if (unlikely(pos->offset == EOF)) + return EOF; + ctf_pos_get_event(pos); + /* + * This is the EOF check after we've advanced the position in + * ctf_pos_get_event. + */ if (unlikely(pos->offset == EOF)) return EOF; assert(pos->offset < pos->content_size); @@ -408,6 +416,7 @@ void ctf_move_pos_slow(struct ctf_stream_pos *pos, size_t offset, int whence) /* empty packet */ pos->offset = index->data_offset; offset = 0; + whence = SEEK_CUR; goto read_next_packet; } else { pos->offset = EOF; -- 2.34.1