perf symbols: Fix use-after-free in get_plt_got_name()
[linux-2.6-microblaze.git] / tools / perf / util / symbol-elf.c
index c0a2de4..7ef5f6d 100644 (file)
@@ -557,6 +557,7 @@ static bool get_plt_got_name(GElf_Shdr *shdr, size_t i,
        const char *sym_name;
        char *demangled;
        GElf_Sym sym;
+       bool result;
        u32 disp;
 
        if (!di->sorted)
@@ -583,9 +584,11 @@ static bool get_plt_got_name(GElf_Shdr *shdr, size_t i,
 
        snprintf(buf, buf_sz, "%s@plt", sym_name);
 
+       result = *sym_name;
+
        free(demangled);
 
-       return *sym_name;
+       return result;
 }
 
 static int dso__synthesize_plt_got_symbols(struct dso *dso, Elf *elf,