When opening a mmap trace, the index is not created so does not need to
be freed, just add a check before freeing it.
For clarity, this patch also allocates the packet_real_index just after
the packet_cycles_index instead of waiting for the convert timestamp
function.
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
pos->dummy = false;
pos->cur_index = 0;
pos->packet_real_index = NULL;
pos->dummy = false;
pos->cur_index = 0;
pos->packet_real_index = NULL;
pos->packet_cycles_index = g_array_new(FALSE, TRUE,
sizeof(struct packet_index));
pos->packet_cycles_index = g_array_new(FALSE, TRUE,
sizeof(struct packet_index));
+ pos->packet_real_index = g_array_new(FALSE, TRUE,
+ sizeof(struct packet_index));
+ } else {
pos->packet_cycles_index = NULL;
pos->packet_cycles_index = NULL;
+ pos->packet_real_index = NULL;
+ }
switch (open_flags & O_ACCMODE) {
case O_RDONLY:
pos->prot = PROT_READ;
switch (open_flags & O_ACCMODE) {
case O_RDONLY:
pos->prot = PROT_READ;
- (void) g_array_free(pos->packet_cycles_index, TRUE);
- (void) g_array_free(pos->packet_real_index, TRUE);
+ if (pos->packet_cycles_index)
+ (void) g_array_free(pos->packet_cycles_index, TRUE);
+ if (pos->packet_real_index)
+ (void) g_array_free(pos->packet_real_index, TRUE);
cfs = container_of(stream, struct ctf_file_stream,
parent);
stream_pos = &cfs->pos;
cfs = container_of(stream, struct ctf_file_stream,
parent);
stream_pos = &cfs->pos;
- stream_pos->packet_real_index = g_array_new(FALSE, TRUE,
- sizeof(struct packet_index));
-
if (!stream_pos->packet_cycles_index)
continue;
if (!stream_pos->packet_cycles_index)
continue;