This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] sim/arm: Prevent NULL pointer dereference in sim_create_inferior.
- From: Will Newton <will dot newton at linaro dot org>
- To: gdb-patches at sourceware dot org
- Cc: Patch Tracking <patches at linaro dot org>
- Date: Tue, 29 Oct 2013 15:55:27 -0700
- Subject: [PATCH] sim/arm: Prevent NULL pointer dereference in sim_create_inferior.
- Authentication-results: sourceware.org; auth=none
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