diff --git a/cli-runopts.c b/cli-runopts.c
index 91a2f4217378e9950c493bf00035f114d64e8466..b8d304f1c423d61062a2e85fd1a78d77dfbc7f12 100644
--- a/cli-runopts.c
+++ b/cli-runopts.c
@@ -383,6 +383,13 @@ void cli_getopts(int argc, char ** argv) {
 		exit(EXIT_FAILURE);
 	}
 
+#ifdef ENABLE_CLI_PROXYCMD                                                                                                                                   
+	if (cli_opts.proxycmd) {
+		/* To match the common path of m_freeing it */
+		cli_opts.proxycmd = m_strdup(cli_opts.proxycmd);
+	}
+#endif
+
 	if (cli_opts.remoteport == NULL) {
 		cli_opts.remoteport = "22";
 	}