[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 1/5] parallels: Resolve some resource leaks



On 23.01.2013 23:04, John Ferlan wrote:
> Be sure to VIR_FREE(accel) and moved virDomainVideoDefFree() within no_memory
> label to be consistent
> 
> Resolve resource leak in parallelsApplyIfaceParams() when the 'oldnet' is
> allocated locally. Also virCommandFree(cmd) as necessary.
> ---
>  src/parallels/parallels_driver.c | 47 ++++++++++++++++++++++++----------------
>  1 file changed, 28 insertions(+), 19 deletions(-)
> 
> diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
> index 1b47246..9c88d71 100644
> --- a/src/parallels/parallels_driver.c
> +++ b/src/parallels/parallels_driver.c
> @@ -271,17 +271,17 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
>  
>      if (!(tmp = virJSONValueObjectGetString(value, "size"))) {
>          parallelsParseError();
> -        goto cleanup;
> +        goto error;
>      }
>  
>      if (virStrToLong_ul(tmp, &endptr, 10, &mem) < 0) {
>          parallelsParseError();
> -        goto cleanup;
> +        goto error;
>      }
>  
>      if (!STREQ(endptr, "Mb")) {
>          parallelsParseError();
> -        goto cleanup;
> +        goto error;
>      }
>  
>      if (VIR_ALLOC(video) < 0)
> @@ -304,8 +304,9 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
>  
>  no_memory:
>      virReportOOMError();
> -cleanup:
> +    VIR_FREE(accel);
>      virDomainVideoDefFree(video);

While there is not much sense in virDomainVideoDefDree() here with
current code, I agree to use it rather than bare VIR_FREE() esp. when
the code might change and we will forget about it.

Michal


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]