summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorØyvind Harboe <oyvind.harboe@zylin.com>2010-07-07 14:56:56 +0200
committerØyvind Harboe <oyvind.harboe@zylin.com>2010-07-07 17:33:04 +0200
commitdaa02f7d84017f21c3ffa2be9997560d353a8829 (patch)
tree85f1f5d24645790f263888c1bf26e4eeb26261fc /src
parentccaa9edf295e2c763c5a3c32a3f901b1637b99c5 (diff)
downloadopenocd_libswd-daa02f7d84017f21c3ffa2be9997560d353a8829.tar.gz
openocd_libswd-daa02f7d84017f21c3ffa2be9997560d353a8829.tar.bz2
openocd_libswd-daa02f7d84017f21c3ffa2be9997560d353a8829.tar.xz
openocd_libswd-daa02f7d84017f21c3ffa2be9997560d353a8829.zip
transport: fix segfault in transport select
String compare against addresses in range 0 or so due to not checking if there was an active session first. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Diffstat (limited to 'src')
-rw-r--r--src/jtag/transport.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/jtag/transport.c b/src/jtag/transport.c
index cee8ffb3..e431feec 100644
--- a/src/jtag/transport.c
+++ b/src/jtag/transport.c
@@ -281,18 +281,17 @@ COMMAND_HANDLER(handle_transport_select)
return ERROR_FAIL;
case 1: /* "select FOO" */
- if(strcmp(session->name, CMD_ARGV[0]) == 0) {
+ if ((session!= NULL) && strcmp(session->name, CMD_ARGV[0]) == 0) {
/* NOP */
LOG_DEBUG("transport '%s' is already selected",
CMD_ARGV[0]);
return ERROR_OK;
} else {
-
- /* we can't change this session's transport after-the-fact */
- if (session) {
- LOG_ERROR("session's transport is already selected.");
- return ERROR_FAIL;
- }
+ /* we can't change this session's transport after-the-fact */
+ if (session) {
+ LOG_ERROR("session's transport is already selected.");
+ return ERROR_FAIL;
+ }
}
break;