* readelf.c (display_debug_frames): Don't crash for mismatched
authorRichard Henderson <rth@redhat.com>
Mon, 22 Mar 2004 03:55:50 +0000 (03:55 +0000)
committerRichard Henderson <rth@redhat.com>
Mon, 22 Mar 2004 03:55:50 +0000 (03:55 +0000)
        DW_CFA_restore_state.

binutils/ChangeLog
binutils/readelf.c

index 33cb21908b60fc71889f466dfdca2815da23d40f..2e41bc8b5012c3e572596441f1e09e3e3bf896ff 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-21  Richard Henderson  <rth@redhat.com>
+
+       * readelf.c (display_debug_frames): Don't crash for mismatched
+       DW_CFA_restore_state.
+
 2004-03-19  Alan Modra  <amodra@bigpond.net.au>
 
        * Makefile.am: Run "make dep-am".
index ddbf7819e30d6670eb570a1be83e33820a9ab4f9..3561eff0a6eb915372dc99bd3777c4cd51a57b5d 100644 (file)
@@ -9150,13 +9150,19 @@ display_debug_frames (Elf_Internal_Shdr *section,
              if (! do_debug_frames_interp)
                printf ("  DW_CFA_restore_state\n");
              rs = remembered_state;
-             remembered_state = rs->next;
-             frame_need_space (fc, rs->ncols-1);
-             memcpy (fc->col_type, rs->col_type, rs->ncols);
-             memcpy (fc->col_offset, rs->col_offset, rs->ncols * sizeof (int));
-             free (rs->col_type);
-             free (rs->col_offset);
-             free (rs);
+             if (rs)
+               {
+                 remembered_state = rs->next;
+                 frame_need_space (fc, rs->ncols-1);
+                 memcpy (fc->col_type, rs->col_type, rs->ncols);
+                 memcpy (fc->col_offset, rs->col_offset,
+                         rs->ncols * sizeof (int));
+                 free (rs->col_type);
+                 free (rs->col_offset);
+                 free (rs);
+               }
+             else if (do_debug_frames_interp)
+               printf ("Mismatched DW_CFA_restore_state\n");
              break;
 
            case DW_CFA_def_cfa: