* [PATCH][kernelshark] trace-graph: Fix trace_seq free-before-use
@ 2010-09-05 11:05 Stefan Hajnoczi
2010-09-07 20:28 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2010-09-05 11:05 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-kernel, Stefan Hajnoczi
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>
---
trace-graph.c | 9 ++++++---
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,
*/
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);
}
}
--
1.7.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-07 20:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-05 11:05 [PATCH][kernelshark] trace-graph: Fix trace_seq free-before-use Stefan Hajnoczi
2010-09-07 20:28 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®