summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2020-12-11 10:12:33 +0200
committerPanu Matilainen <pmatilai@redhat.com>2020-12-16 11:09:36 +0200
commit824143989480c5d268b30f31ba7495b54b2fbb3c (patch)
tree9ebb58e7bdca347df9a85b892814302c06be9a85
parent18a2350b55854e69c07d56f1c914edbb1f976094 (diff)
downloadrpm-824143989480c5d268b30f31ba7495b54b2fbb3c.tar.gz
Fix brown paperbag regression in c223d84fbf1ebb7a862f297e65878a2a78653e8e
Only call free on the success path, getaddrinfo() is like most this type functions and only allocates on success and so, in failure we'd end up freeing an uninitialized pointer. Reported by Scott Andrews on rpm-list. (cherry picked from commit 5ce2b5e3121aa07eb1ccf2bc24443c1536bf94d5)
-rw-r--r--build/build.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/build/build.c b/build/build.c
index a6888b77d..5a067c830 100644
--- a/build/build.c
+++ b/build/build.c
@@ -58,11 +58,11 @@ static char * buildHost(void)
if (getaddrinfo(hostname, NULL, &hints, &ai) == 0) {
strcpy(hostname, ai->ai_canonname);
+ freeaddrinfo(ai);
} else {
rpmlog(RPMLOG_WARNING,
_("Could not canonicalize hostname: %s\n"), hostname);
}
- freeaddrinfo(ai);
}
}
free(bhMacro);