From: Con Kolivas <kernel@kolivas.org>
Date: Fri, 25 Feb 2022 22:35:20 +1100
Subject: Fix control->suffix being deallocated as heap memory as reported by
 Pietro Borrello.

Origin: upstream, https://github.com/ckolivas/lrzip/commit/5faf80cd53ecfd16b636d653483144cd12004f46
---
 lrzip.c | 2 +-
 main.c  | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lrzip.c b/lrzip.c
index 6621131..38047b4 100644
--- a/lrzip.c
+++ b/lrzip.c
@@ -1344,7 +1344,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))
diff --git a/main.c b/main.c
index f70c53a..2f5f551 100644
--- a/main.c
+++ b/main.c
@@ -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 */
@@ -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)
