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]

Re: [patch] [sim/moxie] Fix NULL dereferences


On 2/26/2010 7:47 AM, Jan Kratochvil wrote:
Hi,

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

Thanks, please apply this if you haven't already.


AG



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]