args->files_name = stdin_filename;
args->files_file = stdin;
} else {
- args->files_name = optarg;
- args->files_file = fopen(optarg,
+ // If we are called from parse_environment(),
+ // the memory pointed by optarg will be freed
+ // after we return to parse_environment().
+ // We need to duplicate the string.
+ args->files_name = xstrdup(optarg);
+ args->files_file = fopen(args->files_name,
c == OPT_FILES ? "r" : "rb");
if (args->files_file == NULL)
// TRANSLATORS: This is a translatable
// string because French needs a space
// before the colon ("%s : %s").
message_fatal(_("%s: %s"),
- tuklib_mask_nonprint(optarg),
+ tuklib_mask_nonprint(
+ args->files_name),
strerror(errno));
}