Fix memleak

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-12-09 15:57:34 +01:00
parent ce4156b3dd
commit 11bf124056
2 changed files with 30 additions and 0 deletions

29
21705.patch Normal file
View File

@ -0,0 +1,29 @@
From ca52de3b56d5e70232bee29314cd84f5596c1e7f Mon Sep 17 00:00:00 2001
From: Daan De Meyer <daan.j.demeyer@gmail.com>
Date: Thu, 9 Dec 2021 15:46:13 +0100
Subject: [PATCH] process-util: Fix memory leak
---
src/basic/process-util.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 1b96d3ca8543..c97185215847 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -221,9 +221,12 @@ int get_process_cmdline(pid_t pid, size_t max_columns, ProcessCmdlineFlags flags
return -ENOMEM;
/* Drop trailing empty strings. See issue #21186. */
- STRV_FOREACH_BACKWARDS(p, args)
- if (isempty(*p))
- *p = mfree(*p);
+ STRV_FOREACH_BACKWARDS(p, args) {
+ if (!isempty(*p))
+ break;
+
+ *p = mfree(*p);
+ }
ans = quote_command_line(args, shflags);
if (!ans)

View File

@ -92,6 +92,7 @@ GIT_DIR=../../src/systemd/.git git diffab -M v233..master@{2017-06-15} -- hwdb/[
# here, rather than in the next section. Packit CI will drop any
# patches in this range before applying upstream pull requests.
Patch0001: https://github.com/systemd/systemd/pull/21705.patch
# Downstream-only patches (50009999)
# https://bugzilla.redhat.com/show_bug.cgi?id=1738828