[sheepdog] [PATCH v2] Sheepfs: check NULL pointer return of sheepfs_run_cmd function

Hitoshi Mitake mitake.hitoshi at gmail.com
Mon Jul 6 15:00:52 CEST 2015


At Mon, 06 Jul 2015 17:38:10 +0800,
Ziye Yang wrote:
> 
> We do not correctly check the NULL pointer value of sheepfs_run_cmd,
> it should be fixed.
> 
> Signed-off-by: Ziye Yang <ziye.yang at intel.com>
> ---
>  sheepfs/core.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.
Hitoshi

> 
> diff --git a/sheepfs/core.c b/sheepfs/core.c
> index 473cbb5..6f246e1 100644
> --- a/sheepfs/core.c
> +++ b/sheepfs/core.c
> @@ -408,8 +408,10 @@ int main(int argc, char **argv)
>  		exit(1);
>  
>  	t = sheepfs_run_cmd("dog");
> -	if (t && !strlen(t->buf)) {
> +	if (!t || (t && !strlen(t->buf))) {
>  		fprintf(stderr, "command dog not found\n");
> +		if(t)
> +			free(t);
>  		exit(1);
>  	}
>  	strbuf_release(t);
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> https://lists.wpkg.org/mailman/listinfo/sheepdog


More information about the sheepdog mailing list