[PATCH] discover/paths: Cleanup res after getaddrinfo

Samuel Mendoza-Jonas sam at mendozajonas.com
Thu Aug 2 16:12:55 AEST 2018


Fixes Coverity defect #187192.

Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
 discover/paths.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/discover/paths.c b/discover/paths.c
index 174bdae..e30f032 100644
--- a/discover/paths.c
+++ b/discover/paths.c
@@ -586,12 +586,14 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
 
 	/* If the url is remote but network is not yet available queue up this
 	 * load for later */
-	if (url->scheme != pb_url_file &&
-			getaddrinfo(url->host, NULL, NULL, &res) != 0) {
-		pb_log("load task for %s queued pending network\n", url->full);
-		pending_network_jobs_add(task, flags);
-		task->result->status = LOAD_ASYNC;
-		return task->result;
+	if (url->scheme != pb_url_file) {
+		if (getaddrinfo(url->host, NULL, NULL, &res) != 0) {
+			pb_log("load task for %s queued pending network\n", url->full);
+			pending_network_jobs_add(task, flags);
+			task->result->status = LOAD_ASYNC;
+			return task->result;
+		}
+		freeaddrinfo(res);
 	}
 
 	switch (url->scheme) {
-- 
2.18.0



More information about the Petitboot mailing list