Control: tags -1 patch
I've attached a small patch to mitigate the issue with popt.
Håvard
From: =?utf-8?b?IkjDpXZhcmQgRi4gQWFzZW4i?= <havard.f.aa...@pfft.no>
Date: Sat, 15 Oct 2022 18:55:20 +0200
Subject: Handle plugged memory leak from popt
With popt version 1.19, a memory leak was plugged. gdisk (sdisk) assumed
the value returned by poptGetArg() would remain usable forever because
popt has leaked the value for quite a long time.
This patch consist of one incomplete fix, that has been included in the
official repository, and one that of this writing, is still an open PR.
Origin: upstream, https://sourceforge.net/p/gptfdisk/code/ci/5d5e76d369a412bfb3d2cebb5fc0a7509cef878d/
Origin: upstream, https://sourceforge.net/p/gptfdisk/code/merge-requests/28/
Bug-Debian: https://bugs.debian.org/1020446
---
gptcl.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gptcl.cc b/gptcl.cc
index 34c9421..ab95239 100644
--- a/gptcl.cc
+++ b/gptcl.cc
@@ -156,9 +156,10 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
// Assume first non-option argument is the device filename....
device = (char*) poptGetArg(poptCon);
- poptResetContext(poptCon);
if (device != NULL) {
+ device = strdup(device);
+ poptResetContext(poptCon);
JustLooking(); // reset as necessary
BeQuiet(); // Tell called functions to be less verbose & interactive
if (LoadPartitions((string) device)) {
@@ -498,6 +499,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
cerr << "Error encountered; not saving changes.\n";
retval = 4;
} // if
+ free(device);
} // if (device != NULL)
poptFreeContext(poptCon);
return retval;