]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
readprofile: fix memory leak related to boot_uname_r_str() in usage()
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Thu, 25 Dec 2025 15:19:20 +0000 (10:19 -0500)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Thu, 1 Jan 2026 03:50:03 +0000 (22:50 -0500)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
sys-utils/readprofile.c

index 3c200cf4d50bd0d84296a0fa95bbddf4a9654444..0165a33737b80f2f1d3ae4e88a7c7b8796705914 100644 (file)
@@ -91,6 +91,7 @@ static char *boot_uname_r_str(void)
 static void __attribute__((__noreturn__)) usage(void)
 {
        FILE *out = stdout;
+       char *mapfile = boot_uname_r_str();
        fputs(USAGE_HEADER, out);
        fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
 
@@ -100,7 +101,7 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(USAGE_OPTIONS, out);
        fprintf(out,
              _(" -m, --mapfile <mapfile>   (defaults: \"%s\" and\n"
-               "                                      \"%s\")\n"), defaultmap, boot_uname_r_str());
+               "                                      \"%s\")\n"), defaultmap, mapfile);
        fprintf(out,
              _(" -p, --profile <pro-file>  (default:  \"%s\")\n"), defaultpro);
        fputs(_(" -M, --multiplier <mult>   set the profiling multiplier to <mult>\n"), out);
@@ -114,6 +115,7 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(USAGE_SEPARATOR, out);
        fprintf(out, USAGE_HELP_OPTIONS(27));
        fprintf(out, USAGE_MAN_TAIL("readprofile(8)"));
+       free(mapfile);
        exit(EXIT_SUCCESS);
 }