Protect against some memory leaks 88/245788/1
authorMichal Bloch <m.bloch@samsung.com>
Thu, 15 Oct 2020 19:40:58 +0000 (21:40 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 15 Oct 2020 19:40:58 +0000 (21:40 +0200)
Change-Id: I48bba5aa203a609b795777cbe384f64df81f1ad9
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/dwarf/Gfind_proc_info-lsb.c

index bd2c058..fdc5ef6 100644 (file)
@@ -139,6 +139,8 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local)
       if (strcmp (secname, ".debug_frame") == 0)
         {
           *bufsize = sec_hdrs[i].sh_size;
+          if (*buf)
+            free(*buf);
           *buf = malloc (*bufsize);
 
           fseek (f, sec_hdrs[i].sh_offset, SEEK_SET);
@@ -151,6 +153,8 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local)
       else if (strcmp (secname, ".gnu_debuglink") == 0)
         {
           linksize = sec_hdrs[i].sh_size;
+          if (linkbuf)
+            free(linkbuf);
           linkbuf = malloc (linksize);
 
           fseek (f, sec_hdrs[i].sh_offset, SEEK_SET);