aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2012-09-08 11:06:50 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-09-08 16:14:43 -0400
commitbfd14b9a7231e7cf77520bca1848c40c6b6360ae (patch)
tree154f256831fcc91a6ab16591bc74c7c81fc5a1f0 /tools/perf/util/annotate.c
parent12ceaded6b276c13d905cf09f0c1a1322022ea58 (diff)
perf annotate: Make a copy of filename for passing to basename
The basename function may modify the string passed to it, so the string should not be marked const. Signed-off-by: David Ahern <dsahern@gmail.com> Acked-by: Pekka Enberg <penberg@kernel.org> Cc: Irina Tirdea <irina.tirdea@gmail.com> Cc: Pekka Enberg <penberg@kernel.org> Link: http://lkml.kernel.org/r/1347116812-93646-2-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 51ef69c9841d..04eafd3939df 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -984,7 +984,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
984 int context) 984 int context)
985{ 985{
986 struct dso *dso = map->dso; 986 struct dso *dso = map->dso;
987 const char *filename = dso->long_name, *d_filename; 987 char *filename;
988 const char *d_filename;
988 struct annotation *notes = symbol__annotation(sym); 989 struct annotation *notes = symbol__annotation(sym);
989 struct disasm_line *pos, *queue = NULL; 990 struct disasm_line *pos, *queue = NULL;
990 u64 start = map__rip_2objdump(map, sym->start); 991 u64 start = map__rip_2objdump(map, sym->start);
@@ -992,6 +993,10 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
992 int more = 0; 993 int more = 0;
993 u64 len; 994 u64 len;
994 995
996 filename = strdup(dso->long_name);
997 if (!filename)
998 return -ENOMEM;
999
995 if (full_paths) 1000 if (full_paths)
996 d_filename = filename; 1001 d_filename = filename;
997 else 1002 else
@@ -1042,6 +1047,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
1042 } 1047 }
1043 } 1048 }
1044 1049
1050 free(filename);
1051
1045 return more; 1052 return more;
1046} 1053}
1047 1054