Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix control->suffix being deallocated as heap memory as reported by P…
…ietro Borrello.
  • Loading branch information
ckolivas committed Feb 25, 2022
1 parent 30f5be9 commit 5faf80c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lrzip.c
Expand Up @@ -1338,7 +1338,7 @@ bool initialise_control(rzip_control *control)
control->msgerr = stderr;
register_outputfile(control, control->msgout);
control->flags = FLAG_SHOW_PROGRESS | FLAG_KEEP_FILES | FLAG_THRESHOLD;
control->suffix = ".lrz";
control->suffix = strdup(".lrz");
control->compression_level = 7;
control->ramsize = get_ram(control);
if (unlikely(control->ramsize == -1))
Expand Down
6 changes: 4 additions & 2 deletions main.c
Expand Up @@ -458,7 +458,8 @@ int main(int argc, char *argv[])
if (unlikely(STDOUT))
failure("Cannot specify an output filename when outputting to stdout\n");
control->outname = optarg;
control->suffix = "";
dealloc(control->suffix);
control->suffix = strdup("");
break;
case 'O':
if (control->outname) /* can't mix -o and -O */
Expand Down Expand Up @@ -493,7 +494,8 @@ int main(int argc, char *argv[])
failure("Specified output filename already, can't specify an extension.\n");
if (unlikely(STDOUT))
failure("Cannot specify a filename suffix when outputting to stdout\n");
control->suffix = optarg;
dealloc(control->suffix);
control->suffix = strdup(optarg);
break;
case 't':
if (control->outname)
Expand Down

0 comments on commit 5faf80c

Please sign in to comment.