X-Git-Url: https://git.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=4f6660a9272ced8729b17330b897e9a0390102c4;hb=953f5b4231bbbb8269bb0c55b96a1c8c4bb34a59;hp=2fdab2a66a12a723096f361ad37ca52a28055ead;hpb=a6448291834ca7419553a807ee367c719c2956d0;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 2fdab2a6..4f6660a9 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -2151,7 +2151,7 @@ static bool try_bind(int port) { return success; } -int check_port(char *name) { +int check_port(const char *name) { if(try_bind(655)) { return 655; } @@ -3175,10 +3175,7 @@ static int cmd_shell(int argc, char *argv[]) { free(line); rl_basic_word_break_characters = "\t\n "; line = readline(prompt); - - if(line) { - copy = xstrdup(line); - } + copy = line ? xstrdup(line) : NULL; } else { line = fgets(buf, sizeof(buf), stdin); } @@ -3224,6 +3221,9 @@ static int cmd_shell(int argc, char *argv[]) { } if(!strcasecmp(nargv[argc], "exit") || !strcasecmp(nargv[argc], "quit")) { +#ifdef HAVE_READLINE + free(copy); +#endif free(nargv); return result; } @@ -3252,6 +3252,9 @@ static int cmd_shell(int argc, char *argv[]) { } } +#ifdef HAVE_READLINE + free(copy); +#endif free(nargv); if(tty) {