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/arm: Prevent NULL pointer dereference in sim_create_inferior.


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(-)

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)
     {
-- 
1.8.1.4


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