trace-graph: Fix trace_seq free-before-use
PATCH 1/1 trace-graph: Fix trace_seq free-before-use
Commit e892161f731e958980fa977e2d7980f3cf0819ce changed trace_seq to dynamically expand its buffer. In two instances the destroy function was called too early, causing a freed s.buffer to be used.
Signed-off-by Stefan Hajnoczi <[email protected]>
--- trace-graph.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
trace-graph.c +6 -3
@@ -1666,14 +1666,17 @@ static gint draw_event_label(struct graph_info *ginfo, gint i,*/ ret =trace_graph_plot_display_last_event (ginfo, plot, &s,convert_x_to_time (ginfo, p2-1 )); -trace_seq_destroy (&s); -if (!ret) +if (!ret) { +trace_seq_destroy (&s);return p2; + } layout =gtk_widget_create_pango_layout (ginfo->draw, s.buffer);pango_layout_set_font_description (layout, font);pango_layout_get_pixel_size (layout, &text_width, &text_height); +trace_seq_destroy (&s); +/* Lets see if we can print this info */ if (p2 < text_width) start =1 ;
@@ -1967,7 +1970,6 @@ static void draw_timeline(struct graph_info *ginfo, gint width)convert_nano (time, &sec, &usec);trace_seq_init (&s);trace_seq_printf (&s,"%lu.%06lu" , sec, usec); -trace_seq_destroy (&s);gdk_draw_line (ginfo->curr_pixmap, ginfo->draw->style->black_gc, mid, height, mid, height +5 );
@@ -1978,6 +1980,7 @@ static void draw_timeline(struct graph_info *ginfo, gint width)gdk_draw_layout (ginfo->curr_pixmap, ginfo->draw->style->black_gc, mid - (w /2 ), height+10 , layout);g_object_unref (layout); +trace_seq_destroy (&s); } }
Signature · 1 line
1.7.1
Quoted 5 lines · Stefan Hajnoczi
Commit
e892161f731e958980fa977e2d7980f3cf0819cechangedtrace_seqto dynamically expand its buffer. In two instances the destroy function was called too early, causing a freed s.buffer to be used.Signed-off-by Stefan Hajnoczi <[email protected]>
Thanks Stefan, applied!
-- Steve