From: Mathieu Desnoyers Date: Thu, 4 Apr 2013 16:53:14 +0000 (-0400) Subject: Fix: trace_collection_add() add after check X-Git-Tag: v1.1.1~51 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=391a4294edc3f8bbff878516a07570750cb36f99;hp=80b07bd71464ffbf5f681b7519af520cb0d44d3a 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 --- 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,