diff mbox

[ovs-dev] test-ovsdb: fix memory leak reported by valgrind.

Message ID 1453480167-130459-1-git-send-email-u9012063@gmail.com
State Changes Requested
Headers show

Commit Message

William Tu Jan. 22, 2016, 4:29 p.m. UTC
Testcase 1311, 1312: Boolean-distinct queries on scalars, reports leak
below:
    xmalloc (util.c:112)
    do_query_distinct (test-ovsdb.c:1208)
    ovs_cmdl_run_command (command-line.c:121)
    main (test-ovsdb.c:72)

Signed-off-by: William Tu <u9012063@gmail.com>
---
 tests/test-ovsdb.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ben Pfaff Jan. 22, 2016, 4:39 p.m. UTC | #1
On Fri, Jan 22, 2016 at 08:29:27AM -0800, William Tu wrote:
> Testcase 1311, 1312: Boolean-distinct queries on scalars, reports leak
> below:
>     xmalloc (util.c:112)
>     do_query_distinct (test-ovsdb.c:1208)
>     ovs_cmdl_run_command (command-line.c:121)
>     main (test-ovsdb.c:72)
> 
> Signed-off-by: William Tu <u9012063@gmail.com>
> ---
>  tests/test-ovsdb.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
> index 15f41b0..7b774c2 100644
> --- a/tests/test-ovsdb.c
> +++ b/tests/test-ovsdb.c
> @@ -1298,6 +1298,7 @@ do_query_distinct(struct ovs_cmdl_context *ctx)
>  
>      ovsdb_table_destroy(table); /* Also destroys 'ts'. */
>  
> +    free(rows);
>      exit(exit_code);
>  }

Isn't the 'classes' variable in the same function also leaked?
William Tu Jan. 22, 2016, 4:45 p.m. UTC | #2
I think so, too.
However, valgrind does not report any leak related to 'classes'. So I don't
have much confidence.

On Fri, Jan 22, 2016 at 8:39 AM, Ben Pfaff <blp@ovn.org> wrote:

> On Fri, Jan 22, 2016 at 08:29:27AM -0800, William Tu wrote:
> > Testcase 1311, 1312: Boolean-distinct queries on scalars, reports leak
> > below:
> >     xmalloc (util.c:112)
> >     do_query_distinct (test-ovsdb.c:1208)
> >     ovs_cmdl_run_command (command-line.c:121)
> >     main (test-ovsdb.c:72)
> >
> > Signed-off-by: William Tu <u9012063@gmail.com>
> > ---
> >  tests/test-ovsdb.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
> > index 15f41b0..7b774c2 100644
> > --- a/tests/test-ovsdb.c
> > +++ b/tests/test-ovsdb.c
> > @@ -1298,6 +1298,7 @@ do_query_distinct(struct ovs_cmdl_context *ctx)
> >
> >      ovsdb_table_destroy(table); /* Also destroys 'ts'. */
> >
> > +    free(rows);
> >      exit(exit_code);
> >  }
>
> Isn't the 'classes' variable in the same function also leaked?
>
Ben Pfaff Jan. 22, 2016, 5:31 p.m. UTC | #3
I'd go ahead and free it.  If we're wrong, valgrind will tell us about
the invalid free.

On Fri, Jan 22, 2016 at 08:45:28AM -0800, William Tu wrote:
> I think so, too.
> However, valgrind does not report any leak related to 'classes'. So I don't
> have much confidence.
> 
> On Fri, Jan 22, 2016 at 8:39 AM, Ben Pfaff <blp@ovn.org> wrote:
> 
> > On Fri, Jan 22, 2016 at 08:29:27AM -0800, William Tu wrote:
> > > Testcase 1311, 1312: Boolean-distinct queries on scalars, reports leak
> > > below:
> > >     xmalloc (util.c:112)
> > >     do_query_distinct (test-ovsdb.c:1208)
> > >     ovs_cmdl_run_command (command-line.c:121)
> > >     main (test-ovsdb.c:72)
> > >
> > > Signed-off-by: William Tu <u9012063@gmail.com>
> > > ---
> > >  tests/test-ovsdb.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
> > > index 15f41b0..7b774c2 100644
> > > --- a/tests/test-ovsdb.c
> > > +++ b/tests/test-ovsdb.c
> > > @@ -1298,6 +1298,7 @@ do_query_distinct(struct ovs_cmdl_context *ctx)
> > >
> > >      ovsdb_table_destroy(table); /* Also destroys 'ts'. */
> > >
> > > +    free(rows);
> > >      exit(exit_code);
> > >  }
> >
> > Isn't the 'classes' variable in the same function also leaked?
> >
William Tu Jan. 22, 2016, 5:41 p.m. UTC | #4
thanks, I will resubmit the patch.

On Fri, Jan 22, 2016 at 9:31 AM, Ben Pfaff <blp@ovn.org> wrote:

> I'd go ahead and free it.  If we're wrong, valgrind will tell us about
> the invalid free.
>
> On Fri, Jan 22, 2016 at 08:45:28AM -0800, William Tu wrote:
> > I think so, too.
> > However, valgrind does not report any leak related to 'classes'. So I
> don't
> > have much confidence.
> >
> > On Fri, Jan 22, 2016 at 8:39 AM, Ben Pfaff <blp@ovn.org> wrote:
> >
> > > On Fri, Jan 22, 2016 at 08:29:27AM -0800, William Tu wrote:
> > > > Testcase 1311, 1312: Boolean-distinct queries on scalars, reports
> leak
> > > > below:
> > > >     xmalloc (util.c:112)
> > > >     do_query_distinct (test-ovsdb.c:1208)
> > > >     ovs_cmdl_run_command (command-line.c:121)
> > > >     main (test-ovsdb.c:72)
> > > >
> > > > Signed-off-by: William Tu <u9012063@gmail.com>
> > > > ---
> > > >  tests/test-ovsdb.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
> > > > index 15f41b0..7b774c2 100644
> > > > --- a/tests/test-ovsdb.c
> > > > +++ b/tests/test-ovsdb.c
> > > > @@ -1298,6 +1298,7 @@ do_query_distinct(struct ovs_cmdl_context *ctx)
> > > >
> > > >      ovsdb_table_destroy(table); /* Also destroys 'ts'. */
> > > >
> > > > +    free(rows);
> > > >      exit(exit_code);
> > > >  }
> > >
> > > Isn't the 'classes' variable in the same function also leaked?
> > >
>
diff mbox

Patch

diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index 15f41b0..7b774c2 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -1298,6 +1298,7 @@  do_query_distinct(struct ovs_cmdl_context *ctx)
 
     ovsdb_table_destroy(table); /* Also destroys 'ts'. */
 
+    free(rows);
     exit(exit_code);
 }