aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/header.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index dee1ed2f0d1b..726a0eb5f197 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -65,14 +65,15 @@ struct perf_header *perf_header__new(void)
65{ 65{
66 struct perf_header *self = calloc(sizeof(*self), 1); 66 struct perf_header *self = calloc(sizeof(*self), 1);
67 67
68 if (!self) 68 if (self != NULL) {
69 die("nomem"); 69 self->size = 1;
70 70 self->attr = malloc(sizeof(void *));
71 self->size = 1;
72 self->attr = malloc(sizeof(void *));
73 71
74 if (!self->attr) 72 if (self->attr == NULL) {
75 die("nomem"); 73 free(self);
74 self = NULL;
75 }
76 }
76 77
77 return self; 78 return self;
78} 79}
@@ -426,6 +427,9 @@ struct perf_header *perf_header__read(int fd)
426 u64 f_id; 427 u64 f_id;
427 int nr_attrs, nr_ids, i, j; 428 int nr_attrs, nr_ids, i, j;
428 429
430 if (self == NULL)
431 die("nomem");
432
429 if (perf_file_header__read(&f_header, self, fd) < 0) 433 if (perf_file_header__read(&f_header, self, fd) < 0)
430 die("incompatible file format"); 434 die("incompatible file format");
431 435