diff options
-rw-r--r-- | tools/perf/util/symbol-minimal.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c index fa585c63f56a..d7efb03b3f9a 100644 --- a/tools/perf/util/symbol-minimal.c +++ b/tools/perf/util/symbol-minimal.c | |||
@@ -129,6 +129,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size) | |||
129 | 129 | ||
130 | for (i = 0, phdr = buf; i < ehdr.e_phnum; i++, phdr++) { | 130 | for (i = 0, phdr = buf; i < ehdr.e_phnum; i++, phdr++) { |
131 | void *tmp; | 131 | void *tmp; |
132 | long offset; | ||
132 | 133 | ||
133 | if (need_swap) { | 134 | if (need_swap) { |
134 | phdr->p_type = bswap_32(phdr->p_type); | 135 | phdr->p_type = bswap_32(phdr->p_type); |
@@ -140,12 +141,13 @@ int filename__read_build_id(const char *filename, void *bf, size_t size) | |||
140 | continue; | 141 | continue; |
141 | 142 | ||
142 | buf_size = phdr->p_filesz; | 143 | buf_size = phdr->p_filesz; |
144 | offset = phdr->p_offset; | ||
143 | tmp = realloc(buf, buf_size); | 145 | tmp = realloc(buf, buf_size); |
144 | if (tmp == NULL) | 146 | if (tmp == NULL) |
145 | goto out_free; | 147 | goto out_free; |
146 | 148 | ||
147 | buf = tmp; | 149 | buf = tmp; |
148 | fseek(fp, phdr->p_offset, SEEK_SET); | 150 | fseek(fp, offset, SEEK_SET); |
149 | if (fread(buf, buf_size, 1, fp) != 1) | 151 | if (fread(buf, buf_size, 1, fp) != 1) |
150 | goto out_free; | 152 | goto out_free; |
151 | 153 | ||
@@ -178,6 +180,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size) | |||
178 | 180 | ||
179 | for (i = 0, phdr = buf; i < ehdr.e_phnum; i++, phdr++) { | 181 | for (i = 0, phdr = buf; i < ehdr.e_phnum; i++, phdr++) { |
180 | void *tmp; | 182 | void *tmp; |
183 | long offset; | ||
181 | 184 | ||
182 | if (need_swap) { | 185 | if (need_swap) { |
183 | phdr->p_type = bswap_32(phdr->p_type); | 186 | phdr->p_type = bswap_32(phdr->p_type); |
@@ -189,12 +192,13 @@ int filename__read_build_id(const char *filename, void *bf, size_t size) | |||
189 | continue; | 192 | continue; |
190 | 193 | ||
191 | buf_size = phdr->p_filesz; | 194 | buf_size = phdr->p_filesz; |
195 | offset = phdr->p_offset; | ||
192 | tmp = realloc(buf, buf_size); | 196 | tmp = realloc(buf, buf_size); |
193 | if (tmp == NULL) | 197 | if (tmp == NULL) |
194 | goto out_free; | 198 | goto out_free; |
195 | 199 | ||
196 | buf = tmp; | 200 | buf = tmp; |
197 | fseek(fp, phdr->p_offset, SEEK_SET); | 201 | fseek(fp, offset, SEEK_SET); |
198 | if (fread(buf, buf_size, 1, fp) != 1) | 202 | if (fread(buf, buf_size, 1, fp) != 1) |
199 | goto out_free; | 203 | goto out_free; |
200 | 204 | ||