xbmc: add PR4290

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2014-03-05 00:34:49 +01:00
parent a70b3f1b95
commit 4219b7eee9

View File

@ -0,0 +1,36 @@
From f164b7c43efa55d8132eaeaba6ea2cfecd47a4de Mon Sep 17 00:00:00 2001
From: Daniel Burr <dburr@topcon.com>
Date: Fri, 28 Feb 2014 04:36:16 +0100
Subject: [PATCH] Fix memory leakage in python bindings
The python bindings generated by the groovy code generator contain a reference counting bug which results in a memory leak whenever a std::vector is converted to a python list. The following member functions are affected:
* xbmcvfs.listdir
* xbmc.Player.getAvailableSubtitleStreams
* xbmc.Player.getAvailableAudioStreams
* xbmcgui.Control.getPosition
* xbmcgui.Dialog.browse
* xbmcgui.Dialog.browseMultiple
The reference counting bug occurs because PyList_Append() increments the reference count of the item, so the caller needs to call Py_DECREF() because it no longer owns the object.
This bug is especially problematic when running the Watchdog Service Addon since it may result in frequent calls to xbmcvfs.listdir, and each call can leak many kilobytes of data when listing directories containing many files.
---
xbmc/interfaces/python/typemaps/python.vector.outtm | 1 +
1 file changed, 1 insertion(+)
diff --git a/xbmc/interfaces/python/typemaps/python.vector.outtm b/xbmc/interfaces/python/typemaps/python.vector.outtm
index a841283..69dffe8 100644
--- a/xbmc/interfaces/python/typemaps/python.vector.outtm
+++ b/xbmc/interfaces/python/typemaps/python.vector.outtm
@@ -41,6 +41,7 @@
PyObject* pyentry${seq};
${helper.getOutConversion(vectype,'result',method,[ 'result' : 'pyentry' + seq, 'api' : 'entry' + seq, 'sequence' : sequence ])}
PyList_Append(${result}, pyentry${seq});
+ Py_DECREF(pyentry${seq});
}
<%
if (ispointer)
--
1.8.5.5