diff mbox

[ovs-dev] ovsdb-idl: Fix memory leak in ovsdb_idl_condition_add_clause().

Message ID 1471132738-12757-1-git-send-email-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff Aug. 13, 2016, 11:58 p.m. UTC
The function always allocated a clause but didn't use it if it was
going to be a duplicate.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 lib/ovsdb-idl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Flaviof Aug. 15, 2016, 7:08 p.m. UTC | #1
On Sat, Aug 13, 2016 at 7:58 PM, Ben Pfaff <blp@ovn.org> wrote:

> The function always allocated a clause but didn't use it if it was
> going to be a duplicate.
>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
>

Acked-by: Flavio Fernandes <flavio@flaviof.com>



> ---
>  lib/ovsdb-idl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
> index ad0d1e1..7d3d328 100644
> --- a/lib/ovsdb-idl.c
> +++ b/lib/ovsdb-idl.c
> @@ -769,7 +769,6 @@ void ovsdb_idl_condition_add_clause(struct ovsdb_idl
> *idl,
>                                      struct ovsdb_datum *arg)
>  {
>      struct ovsdb_idl_table *table = ovsdb_idl_table_from_class(idl, tc);
> -    struct ovsdb_idl_clause *clause = xzalloc(sizeof *clause);
>      const struct ovsdb_type *type = NULL;
>      struct ovsdb_idl_clause *c;
>
> @@ -782,6 +781,7 @@ void ovsdb_idl_condition_add_clause(struct ovsdb_idl
> *idl,
>          }
>      }
>
> +    struct ovsdb_idl_clause *clause = xzalloc(sizeof *clause);
>      ovs_list_init(&clause->node);
>      clause->function = function;
>      clause->column = column;
> --
> 2.1.3
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
Ben Pfaff Aug. 16, 2016, 12:13 a.m. UTC | #2
On Mon, Aug 15, 2016 at 03:08:04PM -0400, Flaviof wrote:
> On Sat, Aug 13, 2016 at 7:58 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> > The function always allocated a clause but didn't use it if it was
> > going to be a duplicate.
> >
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> >
> 
> Acked-by: Flavio Fernandes <flavio@flaviof.com>

Thanks, applied.
diff mbox

Patch

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index ad0d1e1..7d3d328 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -769,7 +769,6 @@  void ovsdb_idl_condition_add_clause(struct ovsdb_idl *idl,
                                     struct ovsdb_datum *arg)
 {
     struct ovsdb_idl_table *table = ovsdb_idl_table_from_class(idl, tc);
-    struct ovsdb_idl_clause *clause = xzalloc(sizeof *clause);
     const struct ovsdb_type *type = NULL;
     struct ovsdb_idl_clause *c;
 
@@ -782,6 +781,7 @@  void ovsdb_idl_condition_add_clause(struct ovsdb_idl *idl,
         }
     }
 
+    struct ovsdb_idl_clause *clause = xzalloc(sizeof *clause);
     ovs_list_init(&clause->node);
     clause->function = function;
     clause->column = column;