[master] ad0279a49 Fix insignificant memory leak spotted by Coverity

Poul-Henning Kamp phk at FreeBSD.org
Mon Mar 13 08:42:09 UTC 2023


commit ad0279a494f0efb4c47e697053a374bb662c79dd
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 13 08:41:34 2023 +0000

    Fix insignificant memory leak spotted by Coverity

diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 698a6bbe6..c1bdaf812 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -82,9 +82,10 @@ static const char opt_spec[] = "?a:b:CdE:f:Fh:i:I:j:l:M:n:P:p:r:S:s:T:t:VW:x:";
 static void
 usage(void)
 {
-	char buf[1024];
+	char *p;
 
-#define FMT "  %-28s # %s\n"
+#define FMT_NONL "  %-28s # %s"
+#define FMT FMT_NONL "\n"
 
 	printf( "Usage: varnishd [options]\n");
 
@@ -104,8 +105,12 @@ usage(void)
 	printf(FMT, "", "  default: \":80\"");
 	printf(FMT, "-f vclfile", "VCL program");
 	printf(FMT, "", "Can be specified multiple times.");
-	bprintf(buf, "Working directory (default: %s)", VIN_n_Arg(NULL));
-	printf(FMT, "-n dir", buf);
+	printf(FMT, "-n dir", "Working directory");
+
+	p = VIN_n_Arg(NULL);
+	AN(p);
+	printf(FMT_NONL "  default: %s\n", "", "", p);
+	free(p);
 
 	printf("\n-b can be used only once, and not together with -f\n");
 


More information about the varnish-commit mailing list