]> git.sur5r.net Git - openocd/blobdiff - src/server/tcl_server.c
server: avoid the tcl server crashing when there is no target
[openocd] / src / server / tcl_server.c
index d6828f12aab7da54076666ffb38d43cfad1d6d6f..65f71cc988f19f64c652b227bf0bb8c9b41e461d 100644 (file)
@@ -123,7 +123,7 @@ static int tcl_new_connection(struct connection *connection)
        memset(tclc, 0, sizeof(struct tcl_connection));
        connection->priv = tclc;
 
-       struct target *target = get_current_target(connection->cmd_ctx);
+       struct target *target = get_target_by_num(connection->cmd_ctx->current_target);
        if (target != NULL)
                tclc->tc_laststate = target->state;