This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix invalid memory references in gdb/jit.c


These patches fix the case where calling block_open() non-1 amount of times causes seg faults. This is when using the custom jit reader API.

diff --git a/gdb/jit.c b/gdb/jit.c
index e6b3cc25ca..78295f0dc2 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -684,8 +684,11 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
   /* (begin, end) will contain the PC range this entire blockvector
      spans.  */
   BLOCKVECTOR_MAP (bv) = NULL;
-  begin = stab->blocks->begin;
-  end = stab->blocks->end;
+  if (stab->blocks)
+    {
+      begin = stab->blocks->begin;
+      end = stab->blocks->end;
+    }
   BLOCKVECTOR_NBLOCKS (bv) = actual_nblocks;

   /* First run over all the gdb_block objects, creating a real block
@@ -780,7 +783,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)

for (gdb_block_iter = stab->blocks, gdb_block_iter_tmp = gdb_block_iter->next;
        gdb_block_iter;
-       gdb_block_iter = gdb_block_iter_tmp)
+       gdb_block_iter = gdb_block_iter_tmp,
+ gdb_block_iter_tmp = (gdb_block_iter ? gdb_block_iter->next : NULL))
     {
       xfree ((void *) gdb_block_iter->name);
       xfree (gdb_block_iter);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]