discover/paths: Cleanup res after getaddrinfo
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 26 Jul 2018 01:50:33 +0000 (11:50 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 7 Aug 2018 01:25:33 +0000 (11:25 +1000)
Fixes Coverity defect #187192.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/paths.c

index 174bdae16581a8084feeeef993bb61e77cc7b1fb..e30f0320c1f19d5e9e6d5b436ae48ee008f794d4 100644 (file)
@@ -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 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) {
        }
 
        switch (url->scheme) {