[Libguestfs] [PATCH 4/4] php: fix memory leak in OStringList optargs

Richard W.M. Jones rjones at redhat.com
Wed Feb 11 13:54:36 UTC 2015


On Tue, Feb 10, 2015 at 04:42:55PM +0100, Pino Toscano wrote:
> Make sure to free the char** created to convert the arguments.
> ---
>  generator/php.ml | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/generator/php.ml b/generator/php.ml
> index 28903d0..b49bf60 100644
> --- a/generator/php.ml
> +++ b/generator/php.ml
> @@ -458,6 +458,16 @@ PHP_FUNCTION (guestfs_last_error)
>              pr "\n"
>          | Bool _ | Int _ | Int64 _ | Pointer _ -> ()
>          ) args;
> +      List.iter (
> +        function
> +        | OBool n | OInt n | OInt64 n | OString n -> ()
> +        | OStringList n ->
> +            let uc_n = String.uppercase n in
> +            pr "  if ((optargs_s.bitmask & %s_%s_BITMASK) != 0)\n"
> +              c_optarg_prefix uc_n;
> +            pr "    guestfs_efree_stringlist ((char **) optargs_s.%s);\n" n;
> +            pr "\n"
> +      ) optargs;
>  
>        (* Check for errors. *)
>        (match errcode_of_ret ret with

ACK series.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW




More information about the Libguestfs mailing list