diff options
Diffstat (limited to 'tools/perf/util/annotate.c')
| -rw-r--r-- | tools/perf/util/annotate.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 4397a8b6e6cd..aa66791b1bfc 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
| @@ -606,9 +606,19 @@ static struct arch *arch__find(const char *name) | |||
| 606 | int symbol__alloc_hist(struct symbol *sym) | 606 | int symbol__alloc_hist(struct symbol *sym) |
| 607 | { | 607 | { |
| 608 | struct annotation *notes = symbol__annotation(sym); | 608 | struct annotation *notes = symbol__annotation(sym); |
| 609 | const size_t size = symbol__size(sym); | 609 | size_t size = symbol__size(sym); |
| 610 | size_t sizeof_sym_hist; | 610 | size_t sizeof_sym_hist; |
| 611 | 611 | ||
| 612 | /* | ||
| 613 | * Add buffer of one element for zero length symbol. | ||
| 614 | * When sample is taken from first instruction of | ||
| 615 | * zero length symbol, perf still resolves it and | ||
| 616 | * shows symbol name in perf report and allows to | ||
| 617 | * annotate it. | ||
| 618 | */ | ||
| 619 | if (size == 0) | ||
| 620 | size = 1; | ||
| 621 | |||
| 612 | /* Check for overflow when calculating sizeof_sym_hist */ | 622 | /* Check for overflow when calculating sizeof_sym_hist */ |
| 613 | if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry)) | 623 | if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry)) |
| 614 | return -1; | 624 | return -1; |
