[ovs-dev] [PATCH] ovn-trace: Fix small error condition memory leak in trace().

Ben Pfaff blp at ovn.org
Wed Dec 21 22:12:48 UTC 2016


On Wed, Dec 21, 2016 at 02:04:32PM -0800, Justin Pettit wrote:
> Signed-off-by: Justin Pettit <jpettit at ovn.org>
> ---
>  ovn/utilities/ovn-trace.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/ovn/utilities/ovn-trace.c b/ovn/utilities/ovn-trace.c
> index 71798f8..6d8e514 100644
> --- a/ovn/utilities/ovn-trace.c
> +++ b/ovn/utilities/ovn-trace.c
> @@ -1447,7 +1447,9 @@ trace(const char *dp_s, const char *flow_s)
>      char *error = expr_parse_microflow(flow_s, &symtab, &address_sets,
>                                         ovntrace_lookup_port, dp, &uflow);
>      if (error) {
> -        return xasprintf("error parsing flow: %s\n", error);
> +        char *s = xasprintf("error parsing flow: %s\n", error);
> +        free(error);
> +        return s;
>      }

I've often wished for a %s-like format specifier that frees the string
after it prints it.

Acked-by: Ben Pfaff <blp at ovn.org>


More information about the dev mailing list