perf hist: fix objdump output parsing
authorKonstantin Stepanyuk <[email protected]>
Wed, 26 May 2010 22:10:11 +0000 (02:10 +0400)
committerArnaldo Carvalho de Melo <[email protected]>
Tue, 1 Jun 2010 08:44:36 +0000 (05:44 -0300)
hist_entry__annotate() runs objdump with -S option so the output may contain
lines of any format. If a line starts with a colon strtoull() returns 0 and
calculated offset will be negative. This causes perf annotate segfaults.

Make sure that strtoull() has parsed at least one digit.

Cc: David S. Miller <[email protected]>
Cc: Frédéric Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Tom Zanussi <[email protected]>
LKML-Reference: <new-submission>
Signed-off-by: Konstantin Stepanyuk <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/hist.c

index cbf7eae2ce0909326afa68cb534315df11badeae..07f89b66b318e43748f666f495f87b75f6a34462 100644 (file)
@@ -965,7 +965,7 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file,
                 * Parse hexa addresses followed by ':'
                 */
                line_ip = strtoull(tmp, &tmp2, 16);
-               if (*tmp2 != ':')
+               if (*tmp2 != ':' || tmp == tmp2)
                        line_ip = -1;
        }