[pulseaudio-discuss] [PATCH 2/3] pa_get_fqdn: always free addrinfo

Felipe Sateler fsateler at debian.org
Thu Sep 10 17:42:49 PDT 2015


Found by coverity
---
 src/pulse/util.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/pulse/util.c b/src/pulse/util.c
index 305673f..e4e8207 100644
--- a/src/pulse/util.c
+++ b/src/pulse/util.c
@@ -311,8 +311,11 @@ char *pa_get_fqdn(char *s, size_t l) {
     hints.ai_family = AF_UNSPEC;
     hints.ai_flags = AI_CANONNAME;
 
-    if (getaddrinfo(hn, NULL, &hints, &a) < 0 || !a || !a->ai_canonname || !*a->ai_canonname)
+    if (getaddrinfo(hn, NULL, &hints, &a) < 0 || !a || !a->ai_canonname || !*a->ai_canonname) {
+        if (a)
+            freeaddrinfo(a);
         return pa_strlcpy(s, hn, l);
+    }
 
     pa_strlcpy(s, a->ai_canonname, l);
     freeaddrinfo(a);
-- 
2.5.1



More information about the pulseaudio-discuss mailing list