Skip to content

Commit 5faf80c

Browse files
committed
Fix control->suffix being deallocated as heap memory as reported by Pietro Borrello.
1 parent 30f5be9 commit 5faf80c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: lrzip.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ bool initialise_control(rzip_control *control)
13381338
control->msgerr = stderr;
13391339
register_outputfile(control, control->msgout);
13401340
control->flags = FLAG_SHOW_PROGRESS | FLAG_KEEP_FILES | FLAG_THRESHOLD;
1341-
control->suffix = ".lrz";
1341+
control->suffix = strdup(".lrz");
13421342
control->compression_level = 7;
13431343
control->ramsize = get_ram(control);
13441344
if (unlikely(control->ramsize == -1))

Diff for: main.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ int main(int argc, char *argv[])
458458
if (unlikely(STDOUT))
459459
failure("Cannot specify an output filename when outputting to stdout\n");
460460
control->outname = optarg;
461-
control->suffix = "";
461+
dealloc(control->suffix);
462+
control->suffix = strdup("");
462463
break;
463464
case 'O':
464465
if (control->outname) /* can't mix -o and -O */
@@ -493,7 +494,8 @@ int main(int argc, char *argv[])
493494
failure("Specified output filename already, can't specify an extension.\n");
494495
if (unlikely(STDOUT))
495496
failure("Cannot specify a filename suffix when outputting to stdout\n");
496-
control->suffix = optarg;
497+
dealloc(control->suffix);
498+
control->suffix = strdup(optarg);
497499
break;
498500
case 't':
499501
if (control->outname)

0 commit comments

Comments
 (0)