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]

[patch] [sim/moxie] Fix NULL dereferences


Hi,

it looks as obvious to me but I know nothina about either sim or moxie.


Thanks,
Jan


This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=moxie-unknown-elf".
./gdb -nx -ex 'target sim' -ex r 
= crash

2010-02-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* interp.c (sim_create_inferior): Fix crashes on zero PROG_BFD or ARGV.

--- a/sim/moxie/interp.c
+++ b/sim/moxie/interp.c
@@ -1307,11 +1307,12 @@ sim_create_inferior (sd, prog_bfd, argv, env)
   set_initial_gprs ();
   issue_messages = l;
   
-  cpu.asregs.regs[PC_REGNO] = bfd_get_start_address (prog_bfd);
+  if (prog_bfd != NULL)
+    cpu.asregs.regs[PC_REGNO] = bfd_get_start_address (prog_bfd);
 
   /* Copy args into target memory.  */
   avp = argv;
-  for (argc = 0; *avp; avp++)
+  for (argc = 0; avp && *avp; avp++)
     argc++;
 
   /* Target memory looks like this:


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