mirror of
https://git.proxmox.com/git/systemd
synced 2026-02-04 00:15:37 +00:00
This commit was created using the following commands and then fixing up debian/patches/series manually. $ git config diff.renames false $ git rebase --onto debian/208-5 v208 stable/v208-stable $ git checkout -b patch-queue/experimental HEAD $ gbp-pq export --no-patch-numbers $ git add --ignore-removal debian/patches/
68 lines
2.0 KiB
Diff
68 lines
2.0 KiB
Diff
From: =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Date: Fri, 11 Oct 2013 19:33:20 -0400
|
|
Subject: dbus-common: avoid leak in error path
|
|
|
|
src/shared/dbus-common.c:968:33: warning: Potential leak of memory pointed to by 'l'
|
|
return -EINVAL;
|
|
^~~~~~
|
|
---
|
|
src/shared/dbus-common.c | 20 ++++++++++----------
|
|
1 file changed, 10 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/src/shared/dbus-common.c b/src/shared/dbus-common.c
|
|
index c727cae..3ba2d87 100644
|
|
--- a/src/shared/dbus-common.c
|
|
+++ b/src/shared/dbus-common.c
|
|
@@ -934,7 +934,7 @@ int bus_parse_strv_iter(DBusMessageIter *iter, char ***_l) {
|
|
int bus_parse_strv_pairs_iter(DBusMessageIter *iter, char ***_l) {
|
|
DBusMessageIter sub, sub2;
|
|
unsigned n = 0, i = 0;
|
|
- char **l;
|
|
+ _cleanup_strv_free_ char **l = NULL;
|
|
|
|
assert(iter);
|
|
assert(_l);
|
|
@@ -953,6 +953,7 @@ int bus_parse_strv_pairs_iter(DBusMessageIter *iter, char ***_l) {
|
|
l = new(char*, n*2+1);
|
|
if (!l)
|
|
return -ENOMEM;
|
|
+ l[0] = NULL; /* make sure that l is properly terminated at all times */
|
|
|
|
dbus_message_iter_recurse(iter, &sub);
|
|
|
|
@@ -968,26 +969,25 @@ int bus_parse_strv_pairs_iter(DBusMessageIter *iter, char ***_l) {
|
|
return -EINVAL;
|
|
|
|
l[i] = strdup(a);
|
|
- if (!l[i]) {
|
|
- strv_free(l);
|
|
+ if (!l[i])
|
|
return -ENOMEM;
|
|
- }
|
|
+ i++;
|
|
|
|
- l[++i] = strdup(b);
|
|
- if (!l[i]) {
|
|
- strv_free(l);
|
|
+ l[i] = strdup(b);
|
|
+ if (!l[i])
|
|
return -ENOMEM;
|
|
- }
|
|
-
|
|
i++;
|
|
+
|
|
dbus_message_iter_next(&sub);
|
|
}
|
|
|
|
assert(i == n*2);
|
|
l[i] = NULL;
|
|
|
|
- if (_l)
|
|
+ if (_l) {
|
|
*_l = l;
|
|
+ l = NULL; /* avoid freeing */
|
|
+ }
|
|
|
|
return 0;
|
|
}
|