Daniel Veillard wrote:
On Tue, Feb 16, 2010 at 02:42:54PM +0100, Jim Meyering wrote:
> Here are two patches to avoid semblance of a leak.
>
> One adds a useless use of VIR_FREE.
> The other adds an assertion that the pointer to would-be-leaked
> storage is NULL. There's already an assertion in this file,
> so no need to add an "#include ...".
>
> Take your pick.
>
> >From 2070262e7f1a4803e06a6f75bd96091c5754164d Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering(a)redhat.com>
> Date: Tue, 16 Feb 2010 14:34:48 +0100
> Subject: [PATCH] vshCommandParse: placate coverity
>
> There is no real leak here, but Coverity-Prevent thinks there is.
> It does not see that while there are four ways to return from
> vshCommandGetToken with VSH_TK_END, none of them results in allocation
> of a result.
> * tools/virsh.c (vshCommandParse): Add a (currently) useless VIR_FREE,
> to ensure that we never leak when vshCommandGetToken returns VSH_TK_END.
> ---
> tools/virsh.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 7db48d9..4ffa154 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -8222,8 +8222,10 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
>
> str = end;
>
> - if (tk == VSH_TK_END)
> + if (tk == VSH_TK_END) {
> + VIR_FREE(tkdata);
> break;
> + }
> if (tk == VSH_TK_ERROR)
> goto syntaxError;
>
I prefer that one :-)
I've pushed them all.