X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=752b548e766d37bc60cf3fc21215f10eb894fc55;hp=bb94e52770e36641fd8107414229992426ec1e58;hb=c309df1c8522c61ea9f4f108fa2d1eee3a828037;hpb=5909f3321ad43ad55945ab6d3d6bdc1dd9d2cd33 diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index bb94e527..752b548e 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -729,14 +729,6 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence) pos->offset = 0; } else { read_next_packet: - if (pos->cur_index >= pos->packet_cycles_index->len) { - pos->offset = EOF; - return; - } - if (pos->cur_index >= pos->packet_real_index->len) { - pos->offset = EOF; - return; - } switch (whence) { case SEEK_CUR: { @@ -745,6 +737,9 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence) if (pos->offset == EOF) { return; } + assert(pos->cur_index < pos->packet_cycles_index->len); + assert(pos->cur_index < pos->packet_real_index->len); + /* For printing discarded event count */ packet_index = &g_array_index(pos->packet_cycles_index, struct packet_index, pos->cur_index); @@ -782,6 +777,10 @@ void ctf_packet_seek(struct bt_stream_pos *stream_pos, size_t index, int whence) break; } case SEEK_SET: + if (index >= pos->packet_cycles_index->len) { + pos->offset = EOF; + return; + } packet_index = &g_array_index(pos->packet_cycles_index, struct packet_index, index); pos->last_events_discarded = packet_index->events_discarded;