trace-graph: Fix saved pointer corruption in update_last_record()
The saved pointer was created with tracecmd_peek_data() and then set_cpu_to_time()
was called freeing the saved pointer. We could simply reference the pointer if
need be, but using tracecmd_read_data() is a better solution.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/trace-plot-task.c b/trace-plot-task.c
index 552f274..9ca97a3 100644
--- a/trace-plot-task.c
+++ b/trace-plot-task.c
@@ -376,20 +376,23 @@
} else {
static int once;
- saved = tracecmd_peek_data(handle, cpu);
+ saved = tracecmd_read_data(handle, cpu);
set_cpu_to_time(cpu, ginfo, ts);
t2record = tracecmd_read_data(handle, cpu);
trecord = tracecmd_read_prev(handle, t2record);
free_record(t2record);
/* reset cursor back to what it was */
- if (saved)
+ if (saved) {
tracecmd_set_cursor(handle, cpu, saved->offset);
- else {
+ free_record(saved);
+ } else {
saved = tracecmd_read_data(handle, cpu);
if (!once && saved) {
once++;
warning("failed to reset cursor to end!");
}
+ /* saved should always be NULL */
+ free_record(saved);
}
}
if (!trecord)