[PATCH] discover/paths: Cleanup res after getaddrinfo

Samuel Mendoza-Jonas sam at mendozajonas.com
Tue Aug 7 16:05:47 AEST 2018


On Thu, 2018-08-02 at 16:12 +1000, Samuel Mendoza-Jonas wrote:
> Fixes Coverity defect #187192.
> 
> Signed-off-by: Samuel Mendoza-Jonas <sam at 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) {




More information about the Petitboot mailing list