return;
}
assert(pos->cur_index < pos->packet_index->len);
- if (index > 0) {
+ packet_index = &g_array_index(pos->packet_index,
+ struct packet_index, pos->cur_index);
+ if (pos->cur_index > 0) {
prev_index = &g_array_index(pos->packet_index,
- struct packet_index, index - 1);
+ struct packet_index,
+ pos->cur_index - 1);
}
ctf_update_current_packet_index(&file_stream->parent,
prev_index, packet_index);
int import_stream_packet_index(struct ctf_trace *td,
struct ctf_file_stream *file_stream)
{
- struct ctf_stream_declaration *stream;
struct ctf_stream_pos *pos;
struct ctf_packet_index ctf_index;
struct ctf_packet_index_file_hdr index_hdr;
while (fread(&ctf_index, index_hdr.packet_index_len, 1,
pos->index_fp) == 1) {
uint64_t stream_id;
+ struct ctf_stream_declaration *stream = NULL;
memset(&index, 0, sizeof(index));
index.offset = be64toh(ctf_index.offset);
}
file_stream->parent.stream_id = stream_id;
- stream = g_ptr_array_index(td->streams, stream_id);
+ if (stream_id < td->streams->len) {
+ stream = g_ptr_array_index(td->streams, stream_id);
+ }
if (!stream) {
fprintf(stderr, "[error] Stream %" PRIu64
" is not declared in metadata.\n",