aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2010-09-05 07:05:04 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-09-07 16:20:36 -0400
commitd2c4c0df03ec152ff76ab6870ca709119627150c (patch)
treeac7c558abf30be46eb793a3cad70817f75424e5b
parent5ee7a2ea560c069c40c450ddd42f89d856b1366f (diff)
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 <stefanha@linux.vnet.ibm.com> LKML-Reference: <1283684704-5650-1-git-send-email-stefanha@linux.vnet.ibm.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-graph.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/trace-graph.c b/trace-graph.c
index 44c1273..4e91fe8 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -1666,14 +1666,17 @@ static gint draw_event_label(struct graph_info *ginfo, gint i,
1666 */ 1666 */
1667 ret = trace_graph_plot_display_last_event(ginfo, plot, &s, 1667 ret = trace_graph_plot_display_last_event(ginfo, plot, &s,
1668 convert_x_to_time(ginfo, p2-1)); 1668 convert_x_to_time(ginfo, p2-1));
1669 trace_seq_destroy(&s); 1669 if (!ret) {
1670 if (!ret) 1670 trace_seq_destroy(&s);
1671 return p2; 1671 return p2;
1672 }
1672 1673
1673 layout = gtk_widget_create_pango_layout(ginfo->draw, s.buffer); 1674 layout = gtk_widget_create_pango_layout(ginfo->draw, s.buffer);
1674 pango_layout_set_font_description(layout, font); 1675 pango_layout_set_font_description(layout, font);
1675 pango_layout_get_pixel_size(layout, &text_width, &text_height); 1676 pango_layout_get_pixel_size(layout, &text_width, &text_height);
1676 1677
1678 trace_seq_destroy(&s);
1679
1677 /* Lets see if we can print this info */ 1680 /* Lets see if we can print this info */
1678 if (p2 < text_width) 1681 if (p2 < text_width)
1679 start = 1; 1682 start = 1;
@@ -1967,7 +1970,6 @@ static void draw_timeline(struct graph_info *ginfo, gint width)
1967 convert_nano(time, &sec, &usec); 1970 convert_nano(time, &sec, &usec);
1968 trace_seq_init(&s); 1971 trace_seq_init(&s);
1969 trace_seq_printf(&s, "%lu.%06lu", sec, usec); 1972 trace_seq_printf(&s, "%lu.%06lu", sec, usec);
1970 trace_seq_destroy(&s);
1971 1973
1972 gdk_draw_line(ginfo->curr_pixmap, ginfo->draw->style->black_gc, 1974 gdk_draw_line(ginfo->curr_pixmap, ginfo->draw->style->black_gc,
1973 mid, height, mid, height + 5); 1975 mid, height, mid, height + 5);
@@ -1978,6 +1980,7 @@ static void draw_timeline(struct graph_info *ginfo, gint width)
1978 gdk_draw_layout(ginfo->curr_pixmap, ginfo->draw->style->black_gc, 1980 gdk_draw_layout(ginfo->curr_pixmap, ginfo->draw->style->black_gc,
1979 mid - (w / 2), height+10, layout); 1981 mid - (w / 2), height+10, layout);
1980 g_object_unref(layout); 1982 g_object_unref(layout);
1983 trace_seq_destroy(&s);
1981 } 1984 }
1982} 1985}
1983 1986