From 4dec8fda634d31a4ee09488ee30909fc9fe11b54 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 24 Nov 2024 23:15:24 +0000 Subject: [PATCH] pscp -ls: fix a segfault just before exiting. I had allocated a string, advanced a pointer along it, and then freed that pointer instead of the pointer to the start of the string. I'd already applied the correct fix in tolocal() in commit 841bf321d419d85, but it needed applying in get_dir_list() too. --- pscp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pscp.c b/pscp.c index e213d1e7..e3bbf1f3 100644 --- a/pscp.c +++ b/pscp.c @@ -2130,12 +2130,12 @@ static void tolocal(CmdlineArg **args, size_t nargs) */ static void get_dir_list(CmdlineArg **args, size_t nargs) { - char *wsrc, *host, *user; + char *wsrc_orig, *wsrc, *host, *user; const char *src; const char *q; char c; - wsrc = dupstr(cmdline_arg_to_str(args[0])); + wsrc = wsrc_orig = dupstr(cmdline_arg_to_str(args[0])); /* Separate host from filename */ host = wsrc; @@ -2186,7 +2186,7 @@ static void get_dir_list(CmdlineArg **args, size_t nargs) stripctrl_free(scc); } - sfree(wsrc); + sfree(wsrc_orig); } /*