Revert fix memory leak regressions in popt

This commit is contained in:
zhangruifang2020 2022-08-18 09:51:16 +08:00
parent b1826f6075
commit 74d48edf3e
2 changed files with 4 additions and 40 deletions

View File

@ -1,38 +0,0 @@
From 7182e4618ad5a0186145fc2aa4a98c2229afdfa8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Wed, 5 Jan 2022 14:51:55 +0100
Subject: [PATCH] Fix memory leak regressions in popt 1.18
Fix memory leak regression introduced in commit
7219e1ddc1e8606dda18c1105df0d45d8e8e0e09. Free the actual content, not
the array multiple times, and free on reset.
---
src/popt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/popt.c b/src/popt.c
index 0521c8d..f3f26a3 100644
--- a/src/popt.c
+++ b/src/popt.c
@@ -216,6 +216,9 @@ void poptResetContext(poptContext con)
else
con->os->next = 0;
+ for (i = 0; i < con->numLeftovers; i++) {
+ con->leftovers[i] = _free(con->leftovers[i]);
+ }
con->numLeftovers = 0;
con->nextLeftover = 0;
con->restLeftover = 0;
@@ -1534,7 +1537,7 @@ poptContext poptFreeContext(poptContext con)
con->numExecs = 0;
for (i = 0; i < con->numLeftovers; i++) {
- con->leftovers[i] = _free(&con->leftovers[i]);
+ con->leftovers[i] = _free(con->leftovers[i]);
}
con->leftovers = _free(con->leftovers);
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: popt
Version: 1.18
Release: 2
Release: 3
Summary: C library for parsing command line parameters
License: MIT
URL: https://github.com/rpm-software-management/popt/
@ -12,7 +12,6 @@ Patch2: fix-permit-reading-aliases-remove-left-over-goto-exi.patch
Patch3: fix-coverity-CID-1057440-Unused-pointer-value-UNUSED.patch
Patch4: backport-Consider-POPT_CONTEXT_KEEP_FIRST-during-reset.patch
Patch5: backport-Fix-incorrect-handling-of-leftovers-with-poptStuffAr.patch
Patch6: backport-Fix-memory-leak-regressions-in-popt-1.18.patch
BuildRequires: gcc git gettext
@ -82,6 +81,9 @@ make check
%{_mandir}/man3/%{name}.3.gz
%changelog
* Thu Aug 18 2022 zhangruifang <zhangruifang1@h-partners.com> - 1.18-3
- Revert fix memory leak regressions in popt
* Mon Aug 15 2022 panxiaohe <panxh.life@foxmail.com> - 1.18-2
- Fix incorrect handling of leftovers with poptStuffArgs and memory leak