From 5e1b500b173c7abaf9b78e32d31140c1bd4ba090 Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Tue, 10 Nov 2009 23:10:26 -0800 Subject: [PATCH] fix 'jtag interface' behavior Without this patch, running "openocd -c 'jtag interface'" segfaults. Now, it returns the string "undefined" when the interface is unset. --- src/jtag/tcl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 71efc8b5..b86e006a 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -422,7 +422,8 @@ static int jim_jtag_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)"); return JIM_ERR; } - Jim_SetResultString(goi.interp, jtag_interface->name, -1); + const char *name = jtag_interface ? jtag_interface->name : NULL; + Jim_SetResultString(goi.interp, name ? : "undefined", -1); return JIM_OK; case JTAG_CMD_INIT: if (goi.argc != 0) { -- 2.39.5