[rrd-developers] Bug#529291: rrdtool python bindings leak memory

Tobias Oetiker tobi at oetiker.ch
Mon May 18 16:08:13 CEST 2009


thanks will add
tobi

Today Sebastian Harl wrote:

> tags 529291 + upstream
> thanks
>
> Hi Anders,
>
> On Mon, May 18, 2009 at 03:22:35PM +0200, Anders Hammarquist wrote:
> > The python bindings for the calls rrd_info, rrd_graph_v and rrd_update_v
> > do not properly release references to some objects that they allocate
> > leading to memory leaks. Attacked is a patch to fix it.
>
> Thanks for reporting this and providing a patch. From my POV, the patch
> looks fine, but I'm not into Python at all ;-)
>
> With this message, I've forwarded the patch upstream and I'll include it
> in the next upload to Debian. Tobi, I think this patch should be
> included in 1.3 - 1.2 is (quite obviously) not affected.
>
> > Index: trunk/bindings/python/rrdtoolmodule.c
> > ===================================================================
> > --- trunk/bindings/python/rrdtoolmodule.c	(revision 1440)
> > +++ trunk/bindings/python/rrdtoolmodule.c	(working copy)
> > @@ -435,6 +435,7 @@
> >          }
> >          if (val) {
> >              PyDict_SetItemString(r, data->key, val);
> > +            Py_DECREF(val);
> >          }
> >          data = data->next;
> >      }
> > @@ -459,10 +460,13 @@
> >      if ((data = rrd_info(argc, argv)) == NULL) {
> >          PyErr_SetString(ErrorObject, rrd_get_error());
> >          rrd_clear_error();
> > -        return NULL;
> > +        r = NULL;
> > +    } else {
> > +        r = PyDict_FromInfo(data);
> > +        rrd_info_free(data);
> >      }
> > -    r = PyDict_FromInfo(data);
> > -    rrd_info_free(data);
> > +
> > +    destroy_args(&argv);
> >      return r;
> >  }
> >
> > @@ -484,10 +488,13 @@
> >      if ((data = rrd_graph_v(argc, argv)) == NULL) {
> >          PyErr_SetString(ErrorObject, rrd_get_error());
> >          rrd_clear_error();
> > -        return NULL;
> > +        r = NULL;
> > +    } else {
> > +        r = PyDict_FromInfo(data);
> > +        rrd_info_free(data);
> >      }
> > -    r = PyDict_FromInfo(data);
> > -    rrd_info_free(data);
> > +
> > +    destroy_args(&argv);
> >      return r;
> >  }
> >
> > @@ -509,10 +516,13 @@
> >      if ((data = rrd_update_v(argc, argv)) == NULL) {
> >          PyErr_SetString(ErrorObject, rrd_get_error());
> >          rrd_clear_error();
> > -        return NULL;
> > +        r = NULL;
> > +    } else {
> > +        r = PyDict_FromInfo(data);
> > +        rrd_info_free(data);
> >      }
> > -    r = PyDict_FromInfo(data);
> > -    rrd_info_free(data);
> > +
> > +    destroy_args(&argv);
> >      return r;
> >  }
>
> Cheers,
> Sebastian
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900



More information about the rrd-developers mailing list