discover/paths: Cleanup res after getaddrinfo
diff mbox series

Message ID 20180802061255.11658-1-sam@mendozajonas.com
State Accepted
Headers show
Series
  • discover/paths: Cleanup res after getaddrinfo
Related show

Commit Message

samjonas Aug. 2, 2018, 6:12 a.m. UTC
Fixes Coverity defect #187192.

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

Comments

samjonas Aug. 7, 2018, 6:05 a.m. UTC | #1
On Thu, 2018-08-02 at 16:12 +1000, Samuel Mendoza-Jonas wrote:
> Fixes Coverity defect #187192.
> 
> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
> ---

Merged as a244dded

>  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) {

Patch
diff mbox series

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) {