From 391a4294edc3f8bbff878516a07570750cb36f99 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 4 Apr 2013 12:53:14 -0400 Subject: [PATCH] Fix: trace_collection_add() add after check Fix segmentation fault by adding trace into trace collection only after check for time correlation has succeeded. Reported-by: Etienne Bergeron Signed-off-by: Mathieu Desnoyers --- lib/trace-collection.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/trace-collection.c b/lib/trace-collection.c index 608a6e45..c5c875c9 100644 --- a/lib/trace-collection.c +++ b/lib/trace-collection.c @@ -164,8 +164,6 @@ int bt_trace_collection_add(struct trace_collection *tc, return -EINVAL; trace = container_of(td, struct ctf_trace, parent); - g_ptr_array_add(tc->array, td); - trace->collection = tc; if (tc->array->len > 1) { struct clock_match clock_match = { @@ -187,6 +185,9 @@ int bt_trace_collection_add(struct trace_collection *tc, } } + g_ptr_array_add(tc->array, td); + trace->collection = tc; + { struct clock_match clock_match = { .clocks = tc->clocks, -- 2.34.1