|
@@ -606,9 +606,19 @@ static struct arch *arch__find(const char *name)
|
|
int symbol__alloc_hist(struct symbol *sym)
|
|
int symbol__alloc_hist(struct symbol *sym)
|
|
{
|
|
{
|
|
struct annotation *notes = symbol__annotation(sym);
|
|
struct annotation *notes = symbol__annotation(sym);
|
|
- const size_t size = symbol__size(sym);
|
|
|
|
|
|
+ size_t size = symbol__size(sym);
|
|
size_t sizeof_sym_hist;
|
|
size_t sizeof_sym_hist;
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Add buffer of one element for zero length symbol.
|
|
|
|
+ * When sample is taken from first instruction of
|
|
|
|
+ * zero length symbol, perf still resolves it and
|
|
|
|
+ * shows symbol name in perf report and allows to
|
|
|
|
+ * annotate it.
|
|
|
|
+ */
|
|
|
|
+ if (size == 0)
|
|
|
|
+ size = 1;
|
|
|
|
+
|
|
/* Check for overflow when calculating sizeof_sym_hist */
|
|
/* Check for overflow when calculating sizeof_sym_hist */
|
|
if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry))
|
|
if (size > (SIZE_MAX - sizeof(struct sym_hist)) / sizeof(struct sym_hist_entry))
|
|
return -1;
|
|
return -1;
|