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

Re: [libvirt] [PATCH] cgroup.c: avoid unconditional leaks



On Thu, Feb 04, 2010 at 06:14:44AM -0700, Eric Blake wrote:
> According to Jim Meyering on 2/4/2010 3:16 AM:
> > Here's output from "git format-patch -U19 --stdout -1",
> > so you see the context:
> >      for (i = 0; i < ARRAY_CARDINALITY(inherit_values) ; i++) {
> >          char *value;
> > 
> >          rc = virCgroupGetValueStr(parent,
> >                                    VIR_CGROUP_CONTROLLER_CPUSET,
> >                                    inherit_values[i],
> >                                    &value);
> >          if (rc != 0) {
> >              VIR_ERROR("Failed to get %s %d", inherit_values[i], rc);
> >              break;
> >          }
> 
> Is value allocated prior to that break?
> 
> > 
> >          VIR_DEBUG("Inherit %s = %s", inherit_values[i], value);
> > 
> >          rc = virCgroupSetValueStr(group,
> >                                    VIR_CGROUP_CONTROLLER_CPUSET,
> >                                    inherit_values[i],
> >                                    value);
> > +        VIR_FREE(value);
> 
> Or is it only allocated by virCgroupSetValueStr.

The virCgroupGetValueStr() should be allocating it upon successful
return only, and in the error return case it is guarenteed NULL. The 
virCgroupSetValueStr() method is declared 'const char *' IIRC and
merely writes the passed value out to a file

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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