1
0
mirror of https://git.tukaani.org/xz.git synced 2026-10-31 03:14:56 +00:00

xz: Free the filename allocated for --files or --files0

This cleans up leak detection slightly. Otherwise it doesn't matter
because xz is going to exit soon anyway.

Reported-by: Phuc An
Fixes: https://github.com/tukaani-project/xz/pull/232
This commit is contained in:
Lasse Collin 2026-07-21 13:32:05 +03:00
parent 0877609467
commit 7bd6d63b0c
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
3 changed files with 5 additions and 3 deletions

View File

@ -638,7 +638,7 @@ parse_real(args_info *args, int argc, char **argv)
"or '--files0'."));
if (optarg == NULL) {
args->files_name = stdin_filename;
args->files_name = (char *)stdin_filename;
args->files_file = stdin;
} else {
// If we are called from parse_environment(),

View File

@ -19,7 +19,7 @@ typedef struct {
/// Name of the file from which to read filenames. This is NULL
/// if --files or --files0 was not used.
const char *files_name;
char *files_name;
/// File opened for reading from which filenames are read. This is
/// non-NULL only if files_name is non-NULL.

View File

@ -335,8 +335,10 @@ main(int argc, char **argv)
run(name);
}
if (args.files_name != stdin_filename)
if (args.files_name != stdin_filename) {
(void)fclose(args.files_file);
free(args.files_name);
}
}
#ifdef HAVE_DECODERS