[lxc-devel] [PATCH 1/4] c/r: use fclose instead of close

Serge Hallyn serge.hallyn at ubuntu.com
Wed Jun 10 11:55:48 UTC 2015


Quoting Tycho Andersen (tycho.andersen at canonical.com):
> We're leaking the FILE* here while closing the underlying fd; let's just
> close the file and thus close both.
> 
> Reported-by: Coverity
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>

Interesting.  yeah I guess the _IO_FILE has a bunch of extra
cruft to drop.  I wouldn't have thought of that.

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/criu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/criu.c b/src/lxc/criu.c
> index 667f5d9..adcc626 100644
> --- a/src/lxc/criu.c
> +++ b/src/lxc/criu.c
> @@ -279,11 +279,11 @@ static bool criu_version_ok()
>  			goto version_error;
>  
>  version_match:
> -		close(pipes[0]);
> +		fclose(f);
>  		return true;
>  
>  version_error:
> -		close(pipes[0]);
> +		fclose(f);
>  		ERROR("must have criu " CRIU_VERSION " or greater to checkpoint/restore\n");
>  		return false;
>  	}
> -- 
> 2.1.4
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list