readelf/objdump remember_state memory leaks
authorAlan Modra <amodra@gmail.com>
Thu, 8 Jun 2023 10:28:45 +0000 (19:58 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 9 Jun 2023 03:26:12 +0000 (12:56 +0930)
* dwarf.c (display_debug_frames <DW_CFA_restore_state>): Do free
invalid remember_state.

binutils/dwarf.c

index 8a20bf2a349952d3ab97aac1f2705eba4b267552..4f695bf2bcac467963242be2d8ce05e7163ce9bf 100644 (file)
@@ -9823,12 +9823,14 @@ display_debug_frames (struct dwarf_section *section,
                    {
                      warn (_("Invalid column number in saved frame state\n"));
                      fc->ncols = 0;
-                     break;
                    }
-                 memcpy (fc->col_type, rs->col_type,
-                         rs->ncols * sizeof (*rs->col_type));
-                 memcpy (fc->col_offset, rs->col_offset,
-                         rs->ncols * sizeof (*rs->col_offset));
+                 else
+                   {
+                     memcpy (fc->col_type, rs->col_type,
+                             rs->ncols * sizeof (*rs->col_type));
+                     memcpy (fc->col_offset, rs->col_offset,
+                             rs->ncols * sizeof (*rs->col_offset));
+                   }
                  free (rs->col_type);
                  free (rs->col_offset);
                  free (rs);