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

Sebastian Harl sh at tokkee.org
Mon May 18 16:03:25 CEST 2009


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

-- 
Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20090518/4fe8fb9b/attachment.bin 


More information about the rrd-developers mailing list