[Pdbg] [PATCH] libpdbg: Fix segfault when auto-detecting host backend
Alistair Popple
alistair at popple.id.au
Mon Oct 14 13:26:23 AEDT 2019
A NULL-dereference causes a segfault when running on the host with no
backend specified. Instead the backend should be auto-detected.
Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
libpdbg/dtb.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c
index 53e9b73..c0fb374 100644
--- a/libpdbg/dtb.c
+++ b/libpdbg/dtb.c
@@ -83,10 +83,12 @@ static void *ppc_target(void)
char line[256];
FILE *cpuinfo;
- if (!strcmp(pdbg_backend_option, "p8"))
- return &_binary_p8_host_dtb_o_start;
- else if (!strcmp(pdbg_backend_option, "p9"))
- return &_binary_p9_host_dtb_o_start;
+ if (pdbg_backend_option) {
+ if (!strcmp(pdbg_backend_option, "p8"))
+ return &_binary_p8_host_dtb_o_start;
+ else if (!strcmp(pdbg_backend_option, "p9"))
+ return &_binary_p9_host_dtb_o_start;
+ }
cpuinfo = fopen("/proc/cpuinfo", "r");
if (!cpuinfo)
--
2.20.1
More information about the Pdbg
mailing list