diff mbox

sim/arm: Prevent NULL pointer dereference in sim_create_inferior.

Message ID 52703CDF.3070009@linaro.org
State Accepted
Headers show

Commit Message

Will Newton Oct. 29, 2013, 10:55 p.m. UTC
2013-10-30  Will Newton  <will.newton@linaro.org>

	PR gdb/9195
	* arm/wrapper.c (sim_create_inferior): Avoid calling
	bfd_get_mach with a NULL bfd.
---
 sim/arm/wrapper.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Tom Tromey Nov. 7, 2013, 3:20 p.m. UTC | #1
>>>>> "Will" == Will Newton <will.newton@linaro.org> writes:

Will> 2013-10-30  Will Newton  <will.newton@linaro.org>

Will> 	PR gdb/9195
Will> 	* arm/wrapper.c (sim_create_inferior): Avoid calling
Will> 	bfd_get_mach with a NULL bfd.

Ok.

Tom
diff mbox

Patch

diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index a4b7683..cf10e78 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -244,11 +244,15 @@  sim_create_inferior (sd, abfd, argv, env)
   char **arg;

   if (abfd != NULL)
-    ARMul_SetPC (state, bfd_get_start_address (abfd));
+    {
+      ARMul_SetPC (state, bfd_get_start_address (abfd));
+      mach = bfd_get_mach (abfd);
+    }
   else
-    ARMul_SetPC (state, 0);	/* ??? */
-
-  mach = bfd_get_mach (abfd);
+    {
+      ARMul_SetPC (state, 0);	/* ??? */
+      mach = 0;
+    }

   switch (mach)
     {