binutils/dwarf.c abbrev list leak

Message ID ZO6hWsxoNf+p5Lvn@squeak.grove.modra.org
State New
Headers
Series binutils/dwarf.c abbrev list leak |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 warning Patch is already merged

Commit Message

Alan Modra Aug. 30, 2023, 1:54 a.m. UTC
  * dwarf.c (process_debug_info): Call free_abrev_list on
	return paths.
  

Patch

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 80bbc547bb1..9e22a74209e 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -3997,7 +3997,11 @@  process_debug_info (struct dwarf_section * section,
 		    }
 		}
 	      if (dwarf_start_die != 0 && level < saved_level)
-		return true;
+		{
+		  if (list != NULL)
+		    free_abbrev_list (list);
+		  return true;
+		}
 	      continue;
 	    }
 
@@ -4038,6 +4042,8 @@  process_debug_info (struct dwarf_section * section,
 		}
 	      warn (_("DIE at offset %#lx refers to abbreviation number %lu which does not exist\n"),
 		    die_offset, abbrev_number);
+	      if (list != NULL)
+		free_abbrev_list (list);
 	      return false;
 	    }