Merge remote-tracking branches 'asoc/topic/txx9', 'asoc/topic/wm8750', 'asoc/topic...
[cascardo/linux.git] / tools / perf / util / symbol-minimal.c
index fa585c6..d7efb03 100644 (file)
@@ -129,6 +129,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)
 
                for (i = 0, phdr = buf; i < ehdr.e_phnum; i++, phdr++) {
                        void *tmp;
+                       long offset;
 
                        if (need_swap) {
                                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)
                                continue;
 
                        buf_size = phdr->p_filesz;
+                       offset = phdr->p_offset;
                        tmp = realloc(buf, buf_size);
                        if (tmp == NULL)
                                goto out_free;
 
                        buf = tmp;
-                       fseek(fp, phdr->p_offset, SEEK_SET);
+                       fseek(fp, offset, SEEK_SET);
                        if (fread(buf, buf_size, 1, fp) != 1)
                                goto out_free;
 
@@ -178,6 +180,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)
 
                for (i = 0, phdr = buf; i < ehdr.e_phnum; i++, phdr++) {
                        void *tmp;
+                       long offset;
 
                        if (need_swap) {
                                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)
                                continue;
 
                        buf_size = phdr->p_filesz;
+                       offset = phdr->p_offset;
                        tmp = realloc(buf, buf_size);
                        if (tmp == NULL)
                                goto out_free;
 
                        buf = tmp;
-                       fseek(fp, phdr->p_offset, SEEK_SET);
+                       fseek(fp, offset, SEEK_SET);
                        if (fread(buf, buf_size, 1, fp) != 1)
                                goto out_free;