valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0314-basic-fix-error-memleak-in-socket-util.patch

1abbee
From 605a35e6e8dcb2518a1fa8f92fb5fb00a0419345 Mon Sep 17 00:00:00 2001
1abbee
From: David Herrmann <dh.herrmann@gmail.com>
1abbee
Date: Fri, 29 Apr 2016 12:13:06 +0200
1abbee
Subject: [PATCH] basic: fix error/memleak in socket-util
1abbee
1abbee
Probably a typo, checking 'ret' instead of the return value 'p'. This
1abbee
might cause the function to return failure, even though it succeeded.
1abbee
Furthermore, it might leak resources.
1abbee
1abbee
Cherry-picked from: 0810bc568ace619b16e440805e93256730d45541
1abbee
Related: #1331667
1abbee
---
1abbee
 src/shared/socket-util.c | 2 +-
1abbee
 1 file changed, 1 insertion(+), 1 deletion(-)
1abbee
1abbee
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
181b3f
index a4e26b1d8..407d0afee 100644
1abbee
--- a/src/shared/socket-util.c
1abbee
+++ b/src/shared/socket-util.c
1abbee
@@ -544,7 +544,7 @@ int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_
1abbee
 
1abbee
                 } else {
1abbee
                         p = strndup(sa->un.sun_path, sizeof(sa->un.sun_path));
1abbee
-                        if (!ret)
1abbee
+                        if (!p)
1abbee
                                 return -ENOMEM;
1abbee
                 }
1abbee