[pulseaudio-discuss] [PATCH 1/2] pa_get_fqdn: always free addrinfo
Felipe Sateler
fsateler at debian.org
Fri Sep 11 16:15:20 PDT 2015
Also fix the return error code check of getaddrinfo call
Coverity ID: 1323587
---
src/pulse/util.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/pulse/util.c b/src/pulse/util.c
index 305673f..54fe7a2 100644
--- a/src/pulse/util.c
+++ b/src/pulse/util.c
@@ -297,7 +297,7 @@ char *pa_path_get_filename(const char *p) {
char *pa_get_fqdn(char *s, size_t l) {
char hn[256];
#ifdef HAVE_GETADDRINFO
- struct addrinfo *a, hints;
+ struct addrinfo *a = NULL, hints;
#endif
pa_assert(s);
@@ -311,9 +311,14 @@ 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))
return pa_strlcpy(s, hn, l);
+ if (!a->ai_canonname || !*a->ai_canonname) {
+ freeaddrinfo(a);
+ return pa_strlcpy(s, hn, l);
+ }
+
pa_strlcpy(s, a->ai_canonname, l);
freeaddrinfo(a);
return s;
--
2.5.1
More information about the pulseaudio-discuss
mailing list