From d54f52365b582bb06171df88308e1d10527eaf5e Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Thu, 15 Oct 2020 21:40:58 +0200 Subject: [PATCH] Protect against some memory leaks Change-Id: I48bba5aa203a609b795777cbe384f64df81f1ad9 Signed-off-by: Michal Bloch --- src/dwarf/Gfind_proc_info-lsb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dwarf/Gfind_proc_info-lsb.c b/src/dwarf/Gfind_proc_info-lsb.c index bd2c058..fdc5ef6 100644 --- a/src/dwarf/Gfind_proc_info-lsb.c +++ b/src/dwarf/Gfind_proc_info-lsb.c @@ -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); -- 2.7.4